0

私のアプリは今日は正常に起動していましたが、現在このエラーが発生しています

「アプリケーションは、アプリケーションの起動の最後にルート ビュー コントローラーを持つことが期待されています」

コードを変更するように言っている他のスレッドを見てきましたが、この時点に到達するためにコードを変更したことはありません。

デリゲート.h

@interface halo4AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>{
    UIWindow *window;
    UITabBarController *tabBarController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;

@end

デリゲート.m

@implementation halo4AppDelegate

@synthesize window;
@synthesize tabBarController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{   
    sleep(3);
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}


#pragma mark -
#pragma mark Memory management

- (void)dealloc {
    [tabBarController release];
    [window release];
    [super dealloc];
}

@end

私の FirstViewController の xib は、タイトル FirstView.xib 、 ext です

4

1 に答える 1

1

これはエラーではなく、警告のようなものです。

アプリケーションデリゲートには、application:didFinishLaunchingWithOptions:このメソッドで名前が付けられたメソッドがあり、メソッドの終わりの前にこの行を作成する必要がありますself.window.rootViewController = [Some UIViewController]

繰り返しますが、これはエラーではありません。この rootViewController を作成する別の方法がある場合は、rootViewController を無視できます。

編集

メソッドは次のようになります。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
  UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
  UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
  self.tabBarController = [[UITabBarController alloc] init];
  self.tabBarController.viewControllers = @[viewController1, viewController2];
  self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}
于 2012-07-11T00:34:09.120 に答える