推下一个视图时的活动指标-didSelectRowAtIndexPath

|| 我只能在iPhone应用程序中成功推送下一个视图。但是,导致下一个视图检索数据填充“ 0”,有时等待时间可能是几秒钟或更短,具体取决于连接。 在这段时间内,用户可能认为该应用已冻结等。因此,为了解决此问题,我认为实施ѭ1是一个让用户知道该应用正在运行的好方法。 有人可以告诉我该在哪里实现吗? 谢谢。 pushDetailView方法
- (void)pushDetailView {

[tableView deselectRowAtIndexPath:indexPath animated:YES];
//load the clicked cell.
DetailsImageCell *cell = (DetailsImageCell *)[tableView cellForRowAtIndexPath:indexPath];

//init the controller.
AlertsDetailsView *controller = nil;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
    controller = [[AlertsDetailsView alloc] initWithNibName:@\"DetailsView_iPad\" bundle:nil];
} else {
    controller = [[AlertsDetailsView alloc] initWithNibName:@\"DetailsView\" bundle:nil];
}

//set the ID and call JSON in the controller.
[controller setID:[cell getID]];

//show the view.
[self.navigationController pushViewController:controller animated:YES];
    
已邀请:
        您可以使用
didSelectRowAtIndexPath:
方法本身来实现。
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
cell.accessoryView = spinner;
[spinner startAnimating];
[spinner release];
这将在单元格的右侧显示活动指示符,使用户感到正在加载某些东西。 编辑:如果您设置了AccessoriesView并以相同的方法编写加载代码,则仅当所有操作结束后,UI才会更新。一种解决方法是仅在didSelectRowAtIndexPath:方法中设置activityIndi​​cator,然后调用视图控制器以延迟方式推送代码。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {  

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
    cell.accessoryView = spinner;
    [spinner startAnimating];
    [spinner release];

    [self performSelector:@selector(pushDetailView:) withObject:tableView afterDelay:0.1];
}

- (void)pushDetailView:(UITableView *)tableView {

    // Push the detail view here
}
    

要回复问题请先登录注册