在新的开始屏幕后启动应用程序时出错

时间:2012-11-27 20:41:57

标签: iphone ios

我为我的应用添加了一个新的启动屏幕,它不再起作用了。它添加了标题,.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];的行,则应用再次运行。

这是什么?它必须是非常基本的东西,但我找不到它。

0 个答案:

没有答案