Swift如何将数据传递给UINavigation

时间:2016-10-24 07:54:24

标签: swift

我试图将数据传递给UINavigationController我知道如何使用常规视图控制器执行此操作并且它工作正常但是当我尝试使用UINavigationController时我得到一个错误"值typ' UINavigationController'没有会员'可用用户'"我在网上查了这个问题我发现的一切都与使用segue有关。我只在这个项目中使用代码。

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

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

    }

1 个答案:

答案 0 :(得分:2)

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