gpt4 book ai didi

ios - Swift 3 和带抽屉导航的谷歌地图

转载 作者:行者123 更新时间:2023-11-28 15:38:47 25 4
gpt4 key购买 nike

我正在使用 Swift 3.0 和 Xcode 8.2.1 创建一个应用程序。在主屏幕上,背景是 Google map ,还有一个“NavigationDrawer Acvtiviy”。问题是,当我向右或向左滑动时,“边”不会出现,但 map 会移动。如何区分移动 map 和显示右侧或左侧?我在 UIViewController 中的代码是:

class MainMapVC: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.camera(withLatitude:40.4893538, longitude: -3.6827461, zoom: 5.5)
let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
mapView.isMyLocationEnabled = true
mapView.mapType = .satellite
self.view = mapView
}

@IBAction func leftSideButtonTapped(_ sender: Any) {
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.centerContainer?.toggle(MMDrawerSide.left,
animated:true, completion:nil)

}


@IBAction func rightSideButtonTapped(_ sender: Any) {
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.centerContainer?.toggle(MMDrawerSide.right,animated:true, completion:nil)
}


}

AppDelegate 中的代码是:

import UIKit
import GoogleMaps

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
var centerContainer: MMDrawerController?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

GMSServices.provideAPIKey("edcer..erc..er.erc.e.c.")


// Override point for customization after application launch.var rootViewController = self.window!.rootViewControllerlet mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let rootViewController = self.window!.rootViewController!

let mainStoryboard: UIStoryboard = UIStoryboard(name: "MainMap", bundle: nil)

let centerViewController = mainStoryboard.instantiateViewController(withIdentifier: "MainMap") as! MainMapVC
let leftViewController = mainStoryboard.instantiateViewController(withIdentifier: "LeftSideViewController") as! LeftSideViewController
let rightViewController = mainStoryboard.instantiateViewController(withIdentifier: "RightSideViewController") as! RightSideViewController

let leftSideNav = UINavigationController(rootViewController: leftViewController)
let centerNav = UINavigationController(rootViewController: centerViewController)
let rightNav = UINavigationController(rootViewController: rightViewController)

centerContainer = MMDrawerController(center: centerNav, leftDrawerViewController: leftSideNav,rightDrawerViewController:rightNav)
centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.panningCenterView;
centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.panningCenterView;


window!.rootViewController = centerContainer
window!.makeKeyAndVisible()

return true

}

最佳答案

检查以下一个

mapView.settings.consumesGesturesInView = false

关于ios - Swift 3 和带抽屉导航的谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com