在上图中,
选项卡栏中的1.标签栏项目 A - > C - > d 而不是
选项卡栏中的3. tabbar项目 按照顺序 E - > D - >甲
App会记住1.标签栏项目上的D屏幕。我想要" A"屏幕打开。
以下代码;
D ViewController:
@IBAction func goToMapButton(_ sender: Any) {
if let navController = self.tabBarController?.viewControllers?[0] as? UINavigationController{
if let mapController = navController.childViewControllers.first as? MapViewController{
self.tabBarController?.selectedIndex = 0
mapController.zoomToGeo(X: Double(PhotoItemArraySelected[0].photoLon!)!, Y: Double(PhotoItemArraySelected[0].photoLat!)!,TesisAdi: PhotoItemArraySelected[0].photoName)
}
}
dismiss(animated: true, completion: nil)
}
答案 0 :(得分:2)
如果要显示属于选项卡1的屏幕A,屏幕A看起来是MapViewController:
if let navController = self.tabBarController?.viewControllers?[0] as? UINavigationController{
if let mapController = navController.childViewControllers.first as? MapViewController{
self.tabBarController?.selectedIndex = 0
mapController.zoomToGeo(X: Double(PhotoItemArraySelected[0].photoLon!)!, Y: Double(PhotoItemArraySelected[0].photoLat!)!,TesisAdi: PhotoItemArraySelected[0].photoName)
//add this line and to check if it works good or not.
navController.popToViewController(mapController, animated: true)
}
}