【IOS】异步调用--- 简单使用记录
2013-12-20 17:03
344 查看
/×× ×实现功能:店铺被删除后,先显示提示toast.然后,页面休眠5秒后,再返回到店铺列表页面。 ×/ - (void)processDeleteShopError { _isLoadingData = NO; [_tableView refreshScrollViewDataSourceDidFinishedLoading:_tableView]; [self showToast:@"店铺被删除,返回店铺列表页面刷新数据"]; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^{ [NSThread sleepForTimeInterval:5]; dispatch_async(dispatch_get_main_queue(), ^{ [self backToPreController]; }); }); } - (void)backToPreController { [_shopEditDelegate shopDeleted:_shop]; [self.navigationController popToRootViewControllerAnimated:YES]; }
注意和以下代码比较,其效果不一样。
- (void)processDeleteShopError { _isLoadingData = NO; [_tableView refreshScrollViewDataSourceDidFinishedLoading:_tableView]; [self showToast:@"店铺被删除,返回店铺列表页面刷新数据"]; [[NSThread alloc]performSelector:@selector(backToPreController) withObject:nil afterDelay:2]; } - (void) backToPreController { [_shopEditDelegate shopDeleted:_shop]; [self.navigationController popToRootViewControllerAnimated:YES]; }
相关文章推荐
- 使用Java8的函数式接口@FunctionalInterface实现简单异步调用
- iOS-UIActionSheet的简单使用和调用系统相簿
- 使用Promise解决多层异步调用的简单学习
- iOS 开发 - AVSpeechSynthesizer与AVSpeechUtterance使用简单记录
- iOS-UIActionSheet的简单使用和调用系统相簿
- 【ios】使用Block对POST异步操作的简单封装
- 使用Java8的函数式接口@FunctionalInterface实现简单异步调用
- 使用Promise解决多层异步调用的简单学习心得
- phoneGap在iOS上的简单使用:弹出对话框和调用相机
- iOS-Block的简单使用
- iOS 9 关键字的简单使用
- iOS MBProgressHUD的简单使用
- iOS 第三方框架-MBProgressHUD的简单使用
- iOS 使用WKWebView加载h5页面无法调用拨打电话功能
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(7):服务器端和客户端数据类型的自动转换:泛型集合类型
- 使用委托异步调用方法让程序并行运行
- IOS中UITextField和UILabel简单使用
- Spring Boot中使用@Async实现异步调用
- 关于webservice的异步调用简单实例
- iOS performSelector 的简单使用