我有以下代码:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
[tabBarController performSegueWithIdentifier:@"push_display_incomming_call" sender:self];
这显示了我想要正确看到的ViewController。但是现在我想在显示之前更改属性的ViewController的值是Segue,我正在尝试以下但没有成功。
incommingCallViewController *mainController = (incommingCallViewController*) tabBarController;
mainController.name.text = @"Eddwn Paz";
这是来自xCode控制台的堆栈跟踪:
2014-07-10 16:46:09.413 mobile-app[9354:60b] -[OptionsTabBarViewController name]: unrecognized selector sent to instance 0x17552540
2014-07-10 16:46:09.414 mobile-app[9354:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OptionsTabBarViewController name]: unrecognized selector sent to instance 0x17552540'
答案 0 :(得分:2)
假设push_display_incomming_call
segue将IncommingCallViewController
视图控制器显示为模态。所以你应该使用代码:
IncommingCallViewController *callVC =
(IncommingCallViewController *)tabBarController.presentedViewController;
callVC.name.text = @"Eddwn Paz";
<强>说明:强>
您收到错误是因为您尝试将tabBarController
用作incommingCallViewController
的实例,而它是[{1}}的实例,因此它没有必需的UITabBarController
属性。