开发者

Navigation Controller does not load views

开发者 https://www.devze.com 2023-02-20 01:02 出处:网络
I have custom view controller named DRTableViewController In my app delegate, I use the following function to load

I have custom view controller named DRTableViewController

In my app delegate, I use the following function to load

- (BOOL)application:(UIApplication *)application didFinishLaunchi开发者_高级运维ngWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.

    tvc = [[DRTableViewController alloc] init]; // tvc is created with xib


    navCon = [[UINavigationController alloc] initWithRootViewController:tvc];

    [self.window addSubview:[navCon view]]; 

    [navCon release];

    [self.window makeKeyAndVisible];

    return YES;
}

but when I start my application, navigation controller appears but the view inside it is black,

when I use

[self.window addSubview:[tvc view]];

instead of [navCon view]; I can see my view without any problem

Thanks in advance


You need to retain your navigation controller so it is not released.

Create a property for you navigation controller and retain it in the application delegate.

A quick fix is to comment out the line,

[navCon release]

But this will introduce a memory leak.

0

精彩评论

暂无评论...
验证码 换一张
取 消