标签:
给单独的viewcontroller或者在Appdelegate的主页面添加导航条,只要在viewcontroller上添加navigationcontroller,在添加此navigationcontroller即可
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
ViewController *mainView = [[ViewController alloc]init];
UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:mainView];
navi.navigationBar.backgroundColor = [UIColor blueColor];
[self.window setRootViewController:navi];
[self.window makeKeyAndVisible];
return YES;
}
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor]; // --- 字体颜色
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"BJ.png"] forBarMetrics:UIBarMetricsDefault]; // — 背景色
NSArray *array = self.navigationController.viewControllers;
for (UIViewController *vc in array) {
if ([vc isKindOfClass:[BXXXViewController class]]) {
push VC;
}
或者知道每个界面的指针
[self.navigationController
popToViewController: [self.navigationController.viewControllers
objectAtIndex: ([self.navigationController.viewControllers count] -4)]
animated:YES];
在使用时,根据自己返回层的需要,只要改变一下“-4”这个数字就可以达到目的了
iOS viewController添加导航条以及返回跳转选择
标签:
原文地址:http://www.cnblogs.com/Free-Thinker/p/4921729.html