2017-09-12 89 views
1

enter image description here如何將屏幕從一個TabBarItem傳遞到另一個TabBarItem?

在上圖中,

在使用TabBar

選擇1的TabBar項 A - >Ç - > d 和比

在使用TabBar

選定3.的TabBar項 爲了 E - > D - > A

應用程序會記住1. tabbar項上的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) 
    } 

回答

2

如果你想顯示其屬於選項卡1屏幕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) 
    } 
} 
+0

它的工作。謝謝 – Oztemir

+0

@Oztemir,很樂意幫忙!不用謝。 –

相關問題