下面代码说明如何使用iPhone 非官方SDK在读取数据时显示进度条。 以下代码参考了MobileRss。 定义头文件: #import uikit/UIProgressHUD.h @interface EyeCandy : UIApplication { UIProgressHUD * progress; } - ( v
下面代码说明如何使用iPhone 非官方SDK在读取数据时显示进度条。
以下代码参考了MobileRss。
定义头文件:
-
#import "uikit/UIProgressHUD.h"
-
-
@interface EyeCandy : UIApplication {
-
UIProgressHUD *progress;
-
}
-
-
- (void) showProgressHUD:(NSString *)label withWindow:(UIWindow *)w withView:(UIView *)v withRect:(struct CGRect)rect;
-
- (void) hideProgressHUD;
-
-
@end
上面的引号要改成<>。
-
import "EyeCandy.h"
-
-
@implementation EyeCandy
-
- (void)showProgressHUD:(NSString *)label withWindow:(UIWindow *)w withView:(UIView *)v withRect:(struct CGRect)rect
-
{
-
progress = [[UIProgressHUD alloc] initWithWindow: w];
-
[progress setText: label];
-
[progress drawRect: rect];
-
[progress show: YES];
-
-
[v addSubview:progress];
-
}
-
-
- (void)hideProgressHUD
-
{
-
[progress show: NO];
-
[progress removeFromSuperview];
-
}
-
-
@end
使用下面代码调用:
-
// Setup Eye Candy View
-
_eyeCandy = [[[EyeCandy alloc] init] retain];
-
-
// Call loading display
-
[_eyeCandy showProgressHUD:@"Loading …" withWindow:window withView:mainView withRect:CGRectMake(0.0f, 100.0f, 320.0f, 50.0f)];
-
-
// When finished for hiding the "loading text"
-
[_eyeCandy hideProgressHUD];
本文介绍了一种在iPhone应用中使用非官方SDK显示数据加载进度条的方法。通过定义一个名为EyeCandy的类,利用UIProgressHUD组件实现进度提示框的显示与隐藏。此方案参考了MobileRss项目的实现。
733

被折叠的 条评论
为什么被折叠?



