首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从ViewController向AppDelegate上的属性添加值

从ViewController向AppDelegate上的属性添加值
EN

Stack Overflow用户
提问于 2014-07-10 21:23:54
回答 1查看 87关注 0票数 0

我有以下代码:

代码语言:javascript
复制
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
[tabBarController performSegueWithIdentifier:@"push_display_incomming_call" sender:self];

这向我展示了我想要正确看到的ViewController。但是现在我想改变ViewController的属性值在它显示之前是Segue,我正在尝试下面的操作,但没有成功。

代码语言:javascript
复制
incommingCallViewController *mainController = (incommingCallViewController*) tabBarController;
            mainController.name.text = @"Eddwn Paz";

这是来自xCode控制台的堆栈跟踪:

代码语言:javascript
复制
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'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-10 21:36:35

假设push_display_incomming_call segue将IncommingCallViewController视图控制器作为模型呈现。因此,您应该使用代码:

代码语言:javascript
复制
IncommingCallViewController *callVC = 
    (IncommingCallViewController *)tabBarController.presentedViewController;
callVC.name.text = @"Eddwn Paz";

备注:

您收到错误是因为您尝试使用tabBarController作为incommingCallViewController的实例,而它是UITabBarController的实例,因此它没有必需的name属性。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24686549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档