Phi*_*lak 4 iphone cocoa-touch
我正在构建一个基本上是一个Web应用程序.每个数据都必须从Web API中获取.因此,我展示的每个UITableView都需要花费一些时间来填充数据,而我正在努力寻找向用户显示加载屏幕的好方法.
现在我正在弹出一个动作表,但这看起来有点不对劲.理想情况下,我会在桌面上弹出一个空白视图,上面有"正在加载...",然后在数据进入时将其淡出,但我想不出在我的8个地方做到这一点的方法没有大量代码重复的应用程序.
Sag*_*ari 13
根据我的说法,你有两种选择.
对于alertView您必须在.h文件中放置UIAlertView变量.然后放置以下代码 - 当您请求/加载数据时.
av=[[UIAlertView alloc] initWithTitle:@"Loading Data" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
ActInd=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[ActInd startAnimating];
[ActInd setFrame:CGRectMake(125, 60, 37, 37)];
[av addSubview:ActInd];
[av show];
现在,在完成处理后放置以下语句.
[av dismissWithClickedButtonIndex:0 animated:YES];
[av release]; av=nil;
#import "MBProgressHUD.h"
- 在要使用进度视图的位置导入此项.MBProgressHUD *mbProcess;
- 在*.h文件中声明一个变量.mbProcess=[[MBProgressHUD alloc] initWithView:self.view];
mbProcess.labelText=@"Loading Data";
[self.view addSubview:mbProcess];
[mbProcess setDelegate:self];
[mbProcess show:YES];
[mbProcess hide:YES];
#pragma mark -
#pragma mark MBProgressHUDDelegate methods
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[mbProcess removeFromSuperview];
[mbProcess release];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5371 次 |
最近记录: |