您好我檢查了一些帖子,但找不到任何有關我的問題的信息。我已經成功添加了一個按鈕,但有時候會出現後退按鈕。在uinavigationbar iPhone上設置自定義後退按鈕,某些時候返回按鈕的結果在頂部
我的代碼:
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.backBarButtonItem = nil;
[self.navigationItem setHidesBackButton:YES];
UIButton *btn = [UIButton backButton];
[btn addTarget:self action:@selector(popView) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barBtn = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = barBtn;
[barBtn release];
結果:
所以也許有人有一些類似的問題,或者知道我做錯了什麼?
在此先感謝!
你在什麼時候調用這段代碼?它應該在'viewWillAppear'上。 – adig
此鏈接適用於我:http://idevrecipes.com/2011/01/12/how-do-iphone-apps-instagramreederdailybooth-implement-custom-navigationbar-with-variable-width-back-buttons/,http: //www.applausible.com/blog/?p=401 –
@adig我在viewdidload中添加了這個,但現在當我移動到viewwillappear它也沒有幫助.. – Lukas