1

我在我的应用程序中添加了一个新的开始屏幕,但它不再工作了。它添加了标题、.m 和 .xib 文件。

首先,错误:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“ * -[__NSPlaceholderArray initWithObjects:count:]:尝试从对象 [0] 插入 nil 对象”

这是控制器(我没有改变任何东西):

#import "StartViewController.h"

@interface StartViewController ()

@end

@implementation StartViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

}



@end

这是 AppDelegate 中的启动代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[StartViewController alloc] initWithNibName:@"StartViewController" bundle:nil];
    } else {
        //self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
    }
    self.window.rootViewController = self.viewController;

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = navController;


    [self.window makeKeyAndVisible];
    //    [self.window addSubview:navController.view];

    return YES;
}

.xib 称为 StartViewController.xib,只有几个标签和按钮。还没有任何联系。我尝试删除所有内容,但发生了同样的错误。

我进入了调试器,它进入了新控制器的构造函数,以及 viewdidload 方法。异常[self.window makeKeyAndVisible];在委托中的行引发。

如果我只是更改将新控制器连接到旧控制器的线路,self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];则应用程序将再次运行。

它是什么?它一定是非常基本的东西,但我找不到。

4

0 回答 0