我有一个基于窗口的 iPhone 应用程序,其中包含多个选项卡和一个显示在所有这些选项卡上的导航栏控制器。这是一个天气/气候应用程序,所以我希望用户首先选择一个城市,然后在该城市的每个选项卡中显示天气信息(他们可以使用导航栏从任何选项卡返回城市选择。我跟着这个指南:http ://www.youtube.com/watch?v=LBnPfAtswgw但添加了更多具有相同设置的选项卡。所以我获取当前选项卡并像这样实例化应用程序委托:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger currTab;
AppDelegate_iPhone *delegate = [[UIApplication sharedApplication] delegate];
currTab = delegate.rootTabController.selectedIndex;
...
这工作正常,在 viewDidAppear 中调用时返回正确的选定选项卡。然后我的代码推送到相应的视图(在本例中为 UIForecastViewController),如下所示:
if (currTab == 0) {
if (self.forecastViewController == nil) {
UIForecastViewController *chosenCity = [[UIForecastViewController alloc] initWithNibName:@"UIForecastViewController" bundle:nil];
// note forecastViewController is a variable, not the class
self.forecastViewController = chosenCity;
[chosenCity release];
}
forecastViewController.title = [NSString stringWithFormat:@"%@ Forecast",[cityArray objectAtIndex:row]];
[delegate.navController pushViewController:forecastViewController animated:YES];
}
其他一切都正常工作,但 pushViewController 什么也不做。我已经毫无结果地寻找解决方案,那里有一些类似的例子,但没有使用应用程序委托或给我任何结果。希望我已经提到了我应该拥有的一切,任何帮助/建议将不胜感激!问候。