即时通讯有麻烦重写初始化方法为我的故事板中设计的我的CustomViewController。视图控制器自定义初始化方法与故事板
现在即时通讯做(在我mainViewController):
self.customViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomVC"];
self.customViewController.myObject = someObject;
和我在viewDidLoad中(CustomViewController)
[self.label setText:self.myObject.someString];
该工程确定。
但是,这是正确的方法吗?我应该添加一个自定义的init方法(或覆盖)到我的CustomViewController?像initWithObject一样:?我不知道如何调用我的自定义初始化方法,而不是UIStoryboard instantiateViewControllerWithIdentifier:
,并且我没有接到调用init
或initWithNibName
。我可以使用:- (id)initWithCoder:(NSCoder *)decoder
。
请给我一些建议!
谢谢!
你正在做的一切都正确。你可以在你的自定义类中覆盖initWithCoder,也就是你的_customViewController对象的类文件来做自定义init – 2013-07-05 04:19:40