我正在用模態塞格展示UIViewController。 這UIViewController中繼承了一個UINavigationBar的,我已經設置的UIBarButtonItem左側導航欄:隱藏或禁用UINavigationBar中的UIBarButtonItem
我的問題是,當呈現的UIViewController的viewWillAppear中調用方法,我想隱藏UIBarButtonItem,但總是出現UIBarButtonItem。 我已經爲UIViewController聲明瞭一個名爲myCancelButton的UIBarButtonItem,並且我在Interface Builder中引用了它。
這是我到目前爲止已經試過(全部不工作):
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.backBarButtonItem = nil;
self.myCancelButton = nil;
NSMutableArray *barButtonItems = [self.navigationItem.leftBarButtonItems mutableCopy];
[barButtonItems removeObject:self.myCancelButton];
self.navigationItem.leftBarButtonItems = barButtonItems;
[self.navigationItem.leftBarButtonItems delete:self.myCancelButton];
self.navigationController.navigationItem.leftBarButtonItem = nil;
barButtonItems = [self.navigationController.navigationItem.leftBarButtonItems mutableCopy];
[barButtonItems removeObject:self.myCancelButton];
self.navigationController.navigationItem.leftBarButtonItems = barButtonItems;
[self.navigationController.navigationItem.leftBarButtonItems delete:self.myCancelButton];
[self.myCancelButton setWidth:0.01];
self.navigationItem.hidesBackButton = TRUE;
//Even setting enabled to false doesn't work:
[self.myCancelButton setEnabled:FALSE];
}
,這是行不通的。 我已經跑出了想法。 – w3bshark 2013-03-06 12:57:11