ios - uitableviewcontroller,带有 xib,从 appdelegate 加载,从不加载?

标签 ios xcode uitableview

我有一个类型为 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/

相关文章:

iphone - uitableviewcell中的两个部分

iphone - [viewcontroller_name tableView :cellForRowAtIndexPath:]: unrecognized selector sent to instance 0x7b3a630'

ios - 在 Info.plist 中指定 GPU

ios - swift (xcode 9 : code works in tutorial video):unexpectedly found nil while unwrapping an Optional value

xcode - xcode更新到8.0后,React Native run-ios构建失败。

ios - 使用 Storyboards 时如何让 UITable header 贴在屏幕顶部?

ios - 让我们缩短 cell.textLabel 的长度

ios - 如何获取 Objective C 中特定类的所有已分配实例?

ios - 如何在 iOS 中打开和关闭通知?

ios - 无法启动模拟器,因为它已在使用中