iPhone程序读取数据时显示进度窗是本文要介绍的内容,如何在iPhone程序读取数据时显示进度窗?先来看内容。
下面代码说明如何使用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程序读取数据时显示进度窗的内容介绍完了,希望本文对你有所帮助!