1

我有一个应用程序,用户可以从选择轮中选择他们的国家。出现警报并要求他们确认更改。如果他们确认,它会将他们带到不同的视图,然后他们可以从类别列表中选择以显示信息......

类别列表嵌入在导航控制器中,以方便从详细视图“返回”移动到类别选择视图。

整个应用程序嵌入在标签栏控制器中。

它工作正常(在选择他们的国家后,他们被带到选择类别屏幕),除了现在选择类别失去了与选项卡栏控制器的连接,并且无法返回应用程序的其他部分。

这是我的警报视图代码:

- (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

找到答案实际上是关于了解 Tab Bar Controller 的角色,它如何默认为根视图控制器,然后如何使用它来访问各种视图控制器,而不是试图进行 segue。阅读 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 回答