//從當(dāng)前視圖push到目標(biāo)視圖搅窿,如果視圖已經(jīng)存在嘁酿,則不影響堆棧
[self.navigationController?pushViewController:commentListVC?animated:YES];
//返回上一控制器
[self.navigationController?popViewControllerAnimated:YES];
//返回某一控制器
[self.navigationController?popToViewController:[[UIViewController?alloc]?init]?animated:YES];
//返回到根視圖
[self.navigationController?popToRootViewControllerAnimated:YES];
//B?pop?返回A后男应,B是否釋放要看之后的代碼是否再次使用了B,如果后面的代碼還使用到了B殉了,則B所占的內(nèi)存一直保留开仰,有一種情況例外,在內(nèi)存極度不足的情況下薪铜,IOS會遵從一定的策略有可能把B釋放众弓,B再次被使用的時候再重新創(chuàng)建
另外,即使pop后后面的代碼不再使用B了隔箍,那么B的內(nèi)存只是有可能被釋放谓娃,釋放的時機并不一定,這取決于垃圾回收器的回收策略
//去掉返回按鈕的文字顯示
self.navigationItem.backBarButtonItem?=?[[UIBarButtonItem?alloc]?initWithTitle:@""?style:UIBarButtonItemStyleBordered?target:nil?action:NULL];
//自定義左右導(dǎo)航項一
UIButton?*btn1?=?[UIButton?buttonWithType:UIButtonTypeCustom];
UIButton?*btn2?=?[UIButton?buttonWithType:UIButtonTypeCustom];
UIBarButtonItem?*bar1?=?[[UIBarButtonItem?alloc]?initWithCustomView:btn1];
UIBarButtonItem?*bar2?=?[[UIBarButtonItem?alloc]?initWithCustomView:btn2];
//導(dǎo)航欄的左右導(dǎo)航項蜒滩,可以自定義button
self.navigationItem.leftBarButtonItem?=?bar1;
self.navigationItem.rightBarButtonItem?=?bar1;
//也可以添加多個滨达,后面跟數(shù)組,排列順序是依次排列
self.navigationItem.leftBarButtonItems?=?@[bar1,bar2];
self.navigationItem.rightBarButtonItems?=?@[bar1,bar2];
//自定義左右導(dǎo)航項二
viewController.navigationItem.rightBarButtonItem?=?[[UIBarButtonItem?alloc]?initWithImage:[UIImage?imageNamed:@"navItem_course"]?style:UIBarButtonItemStylePlain?target:self?action:@selector(showCourse:)];
viewController.navigationItem.leftBarButtonItem?=?[[UIBarButtonItem?alloc]?initWithTitle:@"注銷"?style:UIBarButtonItemStylePlain?target:self?action:@selector(logOut:)];
//設(shè)置導(dǎo)航欄的標(biāo)題視圖俯艰,可以自定義一個view捡遍,label都可以
self.navigationItem.titleView
//?back?按鈕背景為白色
[self.navigationBar?setTintColor:[UIColor?whiteColor]];
[self.navigationBar?setTitleTextAttributes:[NSDictionary?dictionaryWithObjectsAndKeys:COLOR_WITH_RGB(230,?230,?230),?UITextAttributeTextColor,[UIFont?boldSystemFontOfSize:18.0f],UITextAttributeFont,?nil]];
//設(shè)置導(dǎo)航欄顏色
[self.navigationBar?setBackgroundImage:[UIImage?imageWithColor:COLOR_WITH_RGB(70,?70,?70)?size:CGSizeMake(SCREEN_WIDTH,?KNav_Height)]?forBarMetrics:UIBarMetricsDefault];
//隱藏navigationBar
self.navigationController.navigationBarHidden?=?YES;