pushViewController无所事事在多个标签的应用程序?
-
27-09-2019 - |
题
我有多个选项卡并且其出现在所有这些标签的导航栏控制器基于窗口的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什么都不做。我已经搜查无果的解决方案,在使用应用程序的委托或给我任何结果稍有类似的例子在那里,但没有。我希望我所提到的一切我应该有,任何帮助/建议将非常感激!问候。
解决方案
navController
的delegate
属性是零。我将通过查看是应该设置该代码启动。
你不使用这个的原因吗?
[self.navigationController pushViewController:forecastViewController animated:YES];
不隶属于 StackOverflow