我有一个类型为 ItemsViewController
@interface ItemsViewController : UITableViewController
现在我从 didFinishLaunchingWithOptions 中的 appdelegate 调用,如下所示
ItemsViewController *itemsViewController = [[ItemsViewController alloc] initWithNibName:@"ItemsViewController" bundle:nil];
// Create an instance of a UINavigationController
// its stack contains only itemsViewController
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:itemsViewController];
// Place navigation controller's view in the window hierarchy
[[self window] setRootViewController:navController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
现在在 ItemsViewController.m 文件中我确实点击了这个方法:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
但这里的问题是它从未命中viewdidload方法?我应该寻找什么?我很困惑!!
最佳答案
好吧,我发现了问题,我对这个项目做了太多编辑,以至于我不小心删除了方法 didFinishLaunchingWithOptions 开头最重要的一行。这是:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
不管怎样,我现在要自杀了,请随意推荐一种死亡方法(高乐氏鸡尾酒,走进车流),如果你想写一些关于我的好话发表出来 在我的悼词中也有。
谢谢。
关于ios - uitableviewcontroller,带有 xib,从 appdelegate 加载,从不加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17222310/