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");

}

}

4

1 に答える 1

1

答えを見つけることは、タブバーコントローラーの役割、ルートビューコントローラーとしてのデフォルトの方法、そしてそれを操作してさまざまなビューコントローラーにアクセスする方法を理解することでした。Appleのドキュメントを読むことはこれに役立ちましたが、コードは非常に簡単であることがわかりました。

- (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");

}
}
于 2012-09-26T17:25:57.240 に答える