微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决推下一个视图时的活动指标-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
}
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。