如何在调用 Web 服务之前加载完整的 UIView
how to load complete UIView before web service is call
在我的项目中有左右滑动菜单,所以如果我点击左侧菜单的单元格,UIViewController
将调用此 UIViewControllers viewDidLoad
方法。
我正在调用基于 SOAP 的 Web 服务。
所以我的问题是当我点击 UITableViewCell
. 视图没有完全加载到屏幕时它卡在那里。并且视图已完全加载,当数据来自 Web 服务时,我可以在完整显示中看到。
所以我必须等待数据到来,我才能看到整个 UIView
。
那么如何在第一次点击时加载 UIViewController
? 并且在 UIView
出现后我将放置 activity 指示器,这就是为什么用户至少可以看到数据是载入 UIView
.
在此先感谢任何人都可以帮助我解决这个问题。
编辑:我尝试调用 Web 服务方法 viewWillAppear
- (void)viewDidLoad {
[super viewDidLoad];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//Call ur web service in view did load or appear and add data in datsource of tableview
dispatch_async(dispatch_get_main_queue(), ^{
//table view reload data
});
});
}
- (void)performBackgroundTask
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Do background work (call your Web service method here)
dispatch_async(dispatch_get_main_queue(), ^{
//Update UI
});
});
}
在后台调用 Webservice 并使用主队列加载 Tableview
在我的项目中有左右滑动菜单,所以如果我点击左侧菜单的单元格,UIViewController
将调用此 UIViewControllers viewDidLoad
方法。
我正在调用基于 SOAP 的 Web 服务。
所以我的问题是当我点击 UITableViewCell
. 视图没有完全加载到屏幕时它卡在那里。并且视图已完全加载,当数据来自 Web 服务时,我可以在完整显示中看到。
所以我必须等待数据到来,我才能看到整个 UIView
。
那么如何在第一次点击时加载 UIViewController
? 并且在 UIView
出现后我将放置 activity 指示器,这就是为什么用户至少可以看到数据是载入 UIView
.
在此先感谢任何人都可以帮助我解决这个问题。
编辑:我尝试调用 Web 服务方法 viewWillAppear
- (void)viewDidLoad {
[super viewDidLoad];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//Call ur web service in view did load or appear and add data in datsource of tableview
dispatch_async(dispatch_get_main_queue(), ^{
//table view reload data
});
});
}
- (void)performBackgroundTask
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Do background work (call your Web service method here)
dispatch_async(dispatch_get_main_queue(), ^{
//Update UI
});
});
}
在后台调用 Webservice 并使用主队列加载 Tableview