如何在iPhone程序读取数据时显示进度窗

以下代码参考了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 allocinitWithWindow: 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 allocinitretain];

// 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];



posted @ 2015-12-28 15:37  Bo-tree  阅读(117)  评论(0)    收藏  举报