的确非常牛B的一个例子,看了论坛后面的跟帖,觉得很神,虽然这样的代码如果用了,肯定会悲剧... 哈哈哈.. 因为使用的是UI的一个控件. @interface UIProgressHUD : NSObject - (void) show: (BOOL) yesOrNo; - (UIProgressHUD *) initWithWindow: (UIView *) window; @end //在controller中实现这两个方法,用的地方,调用presentSheet就可以出现效果了 - (void) killHUD: (id) aHUD { [aHUD show:NO]; [aHUD release]; } - (void) presentSheet { // id HUD = [[UIProgressHUD alloc] initWithWindow:[self.view superview]]; id HUD = [[UIProgressHUD alloc] initWithWindow:self.view]; [HUD setText:@"Downloading File. Please wait."]; [HUD show:YES]; [self performSelector:@selector(killHUD:) withObject:HUD afterDelay:5.0]; } 还有一个例子: 定义头文件: 1.#import "uikit/UIProgressHUD.h" 2. 3.@interface EyeCandy : UIApplication { 4. UIProgressHUD *progress; 5.} 6. 7.- (void) showProgressHUD:(NSString *)label withWindow:(UIWindow *)w withView:(UIView *)v withRect:(struct CGRect)rect; 8.- (void) hideProgressHUD; 9. 10.@end 上面的引号要改成<>。 1.import "EyeCandy.h" 2. 3.@implementation EyeCandy 4.- (void)showProgressHUD:(NSString *)label withWindow:(UIWindow *)w withView:(UIView *)v withRect:(struct CGRect)rect 5.{ 6. progress = [[UIProgressHUD alloc] initWithWindow: w]; 7. [progress setText: label]; 8. [progress drawRect: rect]; 9. [progress show: YES]; 10. 11. [v addSubview:progress]; 12.} 13. 14.- (void)hideProgressHUD 15.{ 16. [progress show: NO]; 17. [progress removeFromSuperview]; 18.} 19. 20.@end 使用下面代码调用: 1.// Setup Eye Candy View 2._eyeCandy = [[[EyeCandy alloc] init] retain]; 3. 4.// Call loading display 5.[_eyeCandy showProgressHUD:@"Loading …" withWindow:window withView:mainView withRect:CGRectMake(0.0f, 100.0f, 320.0f, 50.0f)]; 6. 7.// When finished for hiding the "loading text" 8.[_eyeCandy hideProgressHUD];