Creating a “loading…” view using iPhone SDK

后端 未结 7 1579
情歌与酒
情歌与酒 2021-02-01 08:57

How to create that black/gray modal popup kind of view that many apps use, when some long pending operation is in progress?

Like when using location based services, load

7条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 09:05

    This is actually the undocumented (in 2.2.1 anyway) UIProgressHUD. Create one like this:

    In your .h:

    @interface UIProgressHUD : NSObject 
    - (UIProgressHUD *) initWithWindow: (UIView*)aWindow; 
    - (void) show: (BOOL)aShow; 
    - (void) setText: (NSString*)aText; 
    @end 
    

    In your .m:

    - (void) killHUD: (id)aHUD 
    { 
    [aHUD show:NO]; 
    [aHUD release]; 
    } 
    
    - (void) presentSheet 
    { 
    id HUD = [[UIProgressHUD alloc] initWithWindow:[contentView superview]]; 
    [HUD setText:@"Doing something slow. Please wait."]; 
    [HUD show:YES]; 
    [self performSelector:@selector(killHUD:) withObject:HUD afterDelay:5.0]; 
    } 
    

提交回复
热议问题