我確實有這方面的代碼,但由於它在很多文件中,所以我只會將其縮小並在必要時發佈。我相信我可能只是缺少一些方法調用或線程的事情...我有一個導航控制器,其視圖爲視圖,並帶有三個按鈕的工具欄。爲什麼UINavigationController的toolbarItems會在其餘視圖後4-5秒刷新?
觸摸三個按鈕中的一個導致要調用方法,該方法改變了表視圖的數據源,重新加載表,並且還工具欄上的改變按鈕的標題(以及可能的數量)的按鈕(#能爲0〜3)。
還有一個rightBarButtonItem,它推動一個模式的vc,在解散時,它改變dataSource並重新載入表格和按鈕。
問題:觸摸按鈕(#1)會立即產生效果:按鈕將重新繪製新標題並重新載入tableView的數據。但是,當模態vc被解散(表的setter屬性應該導致數據在vc的viewWillAppear之前重新加載),除了按鈕,一切都很好!工具欄上顯示正確數量的UIBarButtonItems,但它們的標題爲空。我在設置toolbarItems屬性的方法中使用了NSLog,並且在日誌顯示「UIBBI數組集合」後,出現帶有[空白]標題的按鈕,4-5秒後出現標題(在方法結束設置他們已經返回)。
我需要在不同的線程中做些什麼嗎?推這個tvc沒有問題,並且#1中描述的方法也不會產生相同的空白標題效果...所以,我很難過。對於LENGTHY的解釋抱歉...試圖完成。但任何幫助將非常感激!
代碼當self.resultsArray更新(從這個觀點被稱爲,前面的其中一個推動它,或者在模式:
- (void)updateBestGuessesButtons
{
if (self.resultsArray.count == 0 || self.resultsArray.count == 1 || !self.bestGuesses) {
[self.navigationController setToolbarHidden:YES animated:YES];
return;
}
[self.navigationController setToolbarHidden:NO animated:YES];
NSMutableArray *toolbarItems = [[NSMutableArray alloc] initWithObjects:[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil], nil];
for (NSString *guess in self.bestGuesses) {
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithTitle:guess
style:UIBarButtonItemStyleBordered
target:self
action:@selector(removeWordsWithLetter:)];
[toolbarItems addObject:button];
}
[toolbarItems addObject:[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil]];
[self setToolbarItems:toolbarItems animated:YES];
}
請發送您設置/創建按鈕的代碼。 –
@PeterSarnowski完成 – 404compilernotfound