如何覆盖UINavigationController中的initWithRootViewController方法?如何覆盖initWithRootViewController
xcode对我来说唯一的方法是在loadFromNibName和loadView等方法。这些方法不会被调用,我需要在启动时将NSNotification添加到navigationcontroller。
我知道这看起来有点像下面的,但我不知道放什么方法体
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
// what goes here?
}
编辑 我想真正的问题是“你怎么自定义初始化”
编辑2
我的导航控制器头
期间的UIViewController@interface AccountViewNavigationController : UINavigationController {
}
@end
实例化我的UINavigationController像这样将导致没有启动方法打破发点
accountViewNavController = [[UINavigationController alloc] initWithRootViewController:accountView];
在哪里,如果我实例,像这样的loadView不会被调用....但它被调用无数次
accountViewNavController = [[UINavigationController alloc] init];
[accountViewNavController initWithRootViewController:accountView NO];
我对这个阶段非常困惑。
你为什么要重写它?如果你正在使用xib,你可以简单地将RootViewController类改为另一个UIViewController子类 – lostInTransit 2011-05-17 11:03:20
我想添加以下内容.. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveMyEvent :) name:@“MyEvent”object :零]; – dubbeat 2011-05-17 11:05:00