我有以下代码:
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'发布于 2014-07-10 21:36:35
假设push_display_incomming_call segue将IncommingCallViewController视图控制器作为模型呈现。因此,您应该使用代码:
IncommingCallViewController *callVC =
(IncommingCallViewController *)tabBarController.presentedViewController;
callVC.name.text = @"Eddwn Paz";备注:
您收到错误是因为您尝试使用tabBarController作为incommingCallViewController的实例,而它是UITabBarController的实例,因此它没有必需的name属性。
https://stackoverflow.com/questions/24686549
复制相似问题