导航控制器不加载视图
我有名为 DRTableViewController
的自定义视图控制器
在我的应用程序委托中,我使用以下函数来加载,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(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;
}
但是当我启动应用程序时,导航控制器出现,但其中的视图是黑色的,
当我使用
[self.window addSubview:[tvc view]];
而不是 < code>[navCon view]; 我可以毫无问题地看到我的视图
提前致谢
I have custom view controller named DRTableViewController
In my app delegate, I use the following function to load
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要保留您的导航控制器,以免其被释放。
为您的导航控制器创建一个属性并将其保留在应用程序委托中。
一个快速修复方法是注释掉该行,
但这会导致内存泄漏。
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,
But this will introduce a memory leak.