切换视图时 UITableView 变慢

发布于 2024-09-11 20:46:11 字数 1128 浏览 5 评论 0原文

我正在开发一个应用程序,它有一个主菜单,然后根据使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软的没边 2024-09-18 20:46:11

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

I sorted it out. I forgot to set the number of rows and such in the next views.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文