单击行后立即使pushViewController转换

时间:2012-12-21 06:54:50

标签: objective-c ios uitableview pushviewcontroller

我看到点击表项后会立即推送到新viewController的应用,然后在加载新视图时显示activityIndicator。我知道如何将activityIndi​​cator添加到ProfileViewController,但是如何在单击项目后立即将表推送到新控制器而不是等待内容加载?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath 
*)indexPath
{
  ProfileViewController *profileViewController = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];

  //profileViewController.title = [[news objectAtIndex:indexPath.row] objectForKey:@"name"];
  profileViewController.newsArticle = [news objectAtIndex:indexPath.row];
  [self.navigationController pushViewController:profileViewController animated:YES];
}

任何帮助或指导都会很精彩。谢谢大家!

1 个答案:

答案 0 :(得分:0)

在viewDidAppear之前,不要对新视图控制器进行操作。然后你启动异步的东西并且不阻塞主线程:

  1. viewDidLoad:设置活动指示器
  2. viewWillAppear:start acrivity indicator
  3. viewDidAppear:触发异步进程
  4. 委托方法/通知/阻止:当流程完成时,用数据更新UI