我的深化發展應用程式iOS 4.2以上版本。 我將我的UINavigationController
分類爲插入兩個UIImageView
,並使導航欄看起來自定義。 一切是偉大的工作,但我有一個小問題。 我創建的自定義UIBarButtonItem
和我的視圖控制器裏面我把他們帶:創建自定義後退鍵的UINavigationController
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];
它也能工作,但問題是,使這項工作,我需要從調用它:
- (void)viewDidAppear:(BOOL)animated ;
所以只有動畫之後出現,我可以看到非定製按鈕1秒之前定製的更換。
(我試圖與viewWillAppear
但隨後沒有在導航欄附加)
我想知道您是否有可能解決此問題的解決方案。 PS:我從不使用IB,一切都是以編程的方式進行的。
來自法國的感謝!
編輯1:這裏是沒有爲viewWillAppear
顯示任何代碼:
- (void)viewWillAppear:(BOOL)animated {
[self setTitle:@"Jeu"];
//Bouton testflight
TIFButton *testFeedbackButton = [[TIFButton alloc]init];
[testFeedbackButton setTitle: @"Envoyer un Feedback" forState:UIControlStateNormal];
[testFeedbackButton addTarget:self action:@selector(launchFeedback) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *testFeedback = [[UIBarButtonItem alloc] initWithCustomView:testFeedbackButton];
self.navigationItem.rightBarButtonItem = testFeedback;
TIFBackButton *backButton = [[TIFBackButton alloc]init];
[backButton setTitle: @"Retour" forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(popToPrecedentViewController) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];
}
這應該* *用'viewWillAppear',但你的'backButton'視圖需要被實例化/創建您指定'self.navigationItem.leftBarButtonItem'之前的工作。 – 2012-02-15 20:09:01
爲什麼你需要從viewDidAppear調用它?爲什麼不從viewDidLoad工作? – Canopus 2012-02-15 20:16:29