设置viewcontoller委托的问题?

时间:2016-11-17 05:35:59

标签: ios iphone swift uinavigationcontroller swift3

我有两个视图控制器A& B.从我发送一些数据到A视图控制器。我的ViewController嵌入了NavigationController。现在我将从下面的代码从A到B.在这种情况下,我的委托方法不会被调用。

let storyboard = UIStoryboard(name: "DropboxView", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "nav_drop") as! UINavigationController
let vc1:DropboxListingViewController = storyboard.instantiateViewController(withIdentifier: "DropboxListingViewController") as! DropboxListingViewController
vc1.CTprotocolDelegate = self
self.present(vc, animated: true, completion: nil) 

请建议更好的方法。

2 个答案:

答案 0 :(得分:1)

您需要从Uncaught ReferenceError: cordova is not defined(…)对象访问DropboxListingViewController,在这种情况下,UINavigationController就是这样。

vc

答案 1 :(得分:0)

Nirav D是正确的。

实际上你的代码存在的问题是它正在创建两个视图控制器'DropboxListingViewController'实例。您将当前视图控制器设置为委托的实例实际上从未加载到内存中,而是导航控制器创建自己的“DropboxListingViewController”实例,您自己没有注册该实例。 @deepak