1

我已經有了一個應用程序,用戶可以從選取器選擇他們的國家。警報出現並要求他們確認更改。如果他們確認,則會將他們轉到不同的視圖,然後他們可以從類別列表中選擇以顯示信息...如何正確地使用故事板與嵌入式選項卡欄和導航控制器相關?

將類別列表嵌入導航控制器中以便於從詳細視圖中移動「返回「到類別選擇視圖。

整個應用程序嵌入在選項卡欄控制器中。

它工作正常(選擇他們的國家後,他們被帶到選擇類別屏幕),除非現在選擇類別已經失去了與選項卡欄控制器的連接,並且沒有辦法返回到應用程序的其他部分。

這裏是我的alertView代碼:

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

if (buttonIndex == 0) { 
NSLog(@"ok"); 

//I tried the following but it doesn't do anything 
//SelectCategory *switchtocategory = [[SelectCategory alloc] init]; 
//[self.navigationController pushViewController:switchtocategory animated:YES]; 

//the following works but loses the tab/navigation bars 
[self performSegueWithIdentifier: @"GoToCategory" sender: self]; 

    } else { 

    NSLog(@"cancel"); 

} 

}

回答

1

找到了答案,是真正關心理解標籤欄控制器的角色,它怎麼默認的根視圖控制器,然後如何一起工作它訪問各種視圖控制器,而不是嘗試繼續。閱讀蘋果公司的文檔對此有所幫助,但代碼結果非常簡單:

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 

if (buttonIndex == 0) { 

    NSLog(@"ok"); 

//the following transitions to tab #3 when the alertView is touched/clicked/dismissed 

    [self.tabBarController setSelectedIndex:2]; 

    } else { 

    NSLog(@"cancel"); 

} 
} 
相關問題