
在程序进行数据处理和交互的时候常常会出现需要等待的情况,这个时候经常得处理方法就是做一个等待界面,俗称Loading View。
一来防止数据处理过程中用户的错误操作。
二来可以减轻用户等待过程中烦躁的情绪。
在view即将出现之前完成数据的
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Your view is about to move onscreen
[self beginLoadingDataFromTheWeb];
[self startShowingLoadingProgress];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// Your view is about to move offscreen
[self saveDataToDisk];
}
iPhone通过GPRS或者3G网络与web-server进行数据交互。
受到显示网络情况的影响常常有数秒钟的延迟。。。所以Loading View 是经常用到的。。。
在操作需要数据交互,可能导致用户等待的操作同事。初始化Loading View
LoadingViewController *lvc = [[LoadingViewController alloc]
initWithTitle:self.title Description:@"Registering User"];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:lvc];
nc.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self.navigationController presentModalViewController:nc animated:NO];
[lvc release];
[nc release];
这里的技巧就是用到了 presentModalViewController
这个技巧就方便在适当的时候 移除 Loading View
根据iPhone SDK自带的API 对网络状态的回馈数据信息进行检测。。。
如果回馈的信息准确无误可以进行下后续操作,即Remove掉之前的Loading-View
用到的方法是 [self dismissModalViewControllerAnimated:NO];
No comments:
Post a Comment