UINavigationController不起作用 [英] UINavigationController not working
问题描述
我在我的应用程序中使用了UITabBar
,但是(由于我自己的原因)我必须将其删除.现在,我的UINavigationControllers
都不起作用.最明显的地方是当我打电话:[self.navigationController pushViewController:myViewController animated:YES];
I was using a UITabBar
for my application but (for my own reasons) I had to remove it. Now none of my UINavigationControllers
work. Where that manifests itself most is when I call: [self.navigationController pushViewController:myViewController animated:YES];
该代码现在什么都不做,因为我没有UINavigationController
,而且我不知道如何制作一个可以工作的代码.
That code now does nothing because I have no UINavigationController
and I don't know how to make one that will work.
推荐答案
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Initialize window components
UINavigationController *myNavController = [[UINavigationController alloc] init];
[self setNavController: myNavController];
[myNavController release];
FirstViewController *cViewController = [[FirstViewController alloc] init];
[self setMyFirstView: cViewController];
[cViewController release];
[self.window addSubview: [self navController].view];
[[self navController] pushViewController: myFirstView animated:YES];
[self.window makeKeyAndVisible];
return YES;
}
这应该可以解决问题.
顺便说一句,您应该在delegate.h中声明以下内容:
By the way, you should declare the following for that in the delegate.h:
@property (nonatomic, retain) UINavigationController *navController;
@property (nonatomic, retain) IBOutlet CatchengoViewController *viewController;
@property (nonatomic, retain) UIViewController *myFirstView;
这篇关于UINavigationController不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!