切换视图时 UITableView 变慢
我正在开发一个应用程序,它有一个主菜单,然后根据使用 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];
}}
I'm working on an app which has a main menu which then switches views based on the menu item clicked using a UINavigationController. Whenever I run my app and click on an item in the menu, it is a good five seconds before the view loads. Is this normal or do I need to do this in another way. Thanks for looking!
My code in RootViewController.m looks like this.
- (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];
}}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我整理了一下。我忘记在下一个视图中设置行数等。
I sorted it out. I forgot to set the number of rows and such in the next views.