切换视图时UITableView变慢

时间:2010-07-27 22:55:30

标签: uitableview uinavigationcontroller if-statement performance didselectrowatindexpath

我正在开发一个应用程序,它有一个主菜单,然后根据使用UINavigationController单击的菜单项切换视图。每当我运行我的应用程序并单击菜单中的某个项目时,在视图加载前五秒钟。这是正常的还是我需要以另一种方式做到这一点。谢谢你的期待!

我在RootViewController.m中的代码看起来像这样。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedMenuOption = [menuOptions objectAtIndex:indexPath.row];
if (selectedMenuOption == @"Trails") {
    TrailsViewController *trailsViewController = [[TrailsViewController alloc] initWithNibName:@"TrailsViewController" bundle:[NSBundle mainBundle]];
    trailsViewController.selectedMenuOption = selectedMenuOption;
    [self.navigationController pushViewController:trailsViewController animated:YES];
    [trailsViewController release];
}
if (selectedMenuOption == @"Bike Shops") {
    ShopsViewController *shopsViewController = [[ShopsViewController alloc] initWithNibName:@"ShopsViewController" bundle:[NSBundle mainBundle]];
    shopsViewController.selectedMenuOption = selectedMenuOption;
    [self.navigationController pushViewController:shopsViewController animated:YES];
    [shopsViewController release];
}}

1 个答案:

答案 0 :(得分:0)

我整理出来了。我忘了在下一个视图中设置行数等。