2016-10-24 89 views
0

我试图将数据传递给UINavigationController我知道如何使用常规视图控制器执行此操作,但它工作正常,但是当我尝试使用UINavigationController执行操作时,出现错误“Value类型'UINavigationController'没有成员'可用用户'“我在网上查询了这个问题,发现我发现的所有东西都与使用segue有关。我只为这个项目使用代码。Swift如何将数据传递给UINavigation

func nearbyUsersWithArray(){ 
     let vc = UINavigationController(rootViewController: NearByUsersViewController()) 

     vc.availaibleUsers = ["item to passed here"] 
     self.present(vc, animated: true, completion: nil) 

    } 

回答

2
let vc = NearByUsersViewController() 
vc.availableUsers = ["item to passed here"] 
let nvc = UINavigationController(rootViewController: vc) 
self.present(nvc, animated: true, completion: nil)