无法设置 UIViewController ios 的属性 [英] Unable to set property of a UIViewController ios
本文介绍了无法设置 UIViewController ios 的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个扩展 UIViewController 的视图控制器.
I have a view controller which extends UIViewController.
@interface MyViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *phoneTxt;
@property (nonatomic, strong) NSDictionary *data;
@end
但是,当我尝试通过以下方式设置视图控制器的属性时:
However when I try to set the property of the view controller by:
MyViewController *vvc = (MyViewController *)[sb instantiateViewControllerWithIdentifier:@"MyVC"];
vvc.data = data;
我收到以下错误:
'NSInvalidArgumentException', reason: '-[UIViewController setData:]: unrecognized selector sent to instance
我已经检查过,视图控制器不是 nil 并且我已经在 MyViewController.m 中合成了属性数据
I have checked, the view controller is not nil and I have synthesized the property data in MyViewController.m
@synthesize data = _data;
为什么我会收到此错误?
Why am I getting this error?
推荐答案
我想你可能忘记在你的故事板/xib 中为你的视图控制器(文件的所有者)设置正确的类,所以它可能被实例化为一个原始的 <代码>UIWievController.
I think you probably forgot to set the proper class for your view controller (File's Owner) in your storyboard/xib, so it probably gets instantiated as a raw UIWievController
.
这篇关于无法设置 UIViewController ios 的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文