开发者

Wait cursor in an iPhone app

开发者 https://www.devze.com 2023-01-08 04:16 出处:网络
Is there an easy way to display a wait animation in the iPhone sdk. I have a screen that will take a few sec开发者_运维问答onds to load, and I\'d like to give the user some feedback that something is

Is there an easy way to display a wait animation in the iPhone sdk. I have a screen that will take a few sec开发者_运维问答onds to load, and I'd like to give the user some feedback that something is happening. Any suggestions?


[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

or

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

will do the trick!

edit: Found this one in an older project, client requested an indicator with better visibility:

-(void)invokeMegaAnnoyingPopup
{
    self.megaAlert = [[[UIAlertView alloc] initWithTitle:@"Please wait..."
        message:nil delegate:self cancelButtonTitle:nil
        otherButtonTitles: nil] autorelease];

    [self.megaAlert show];

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
        initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    indicator.center = CGPointMake(self.megaAlert.bounds.size.width / 2,
                                   self.megaAlert.bounds.size.height - 45);
    [indicator startAnimating];
    [self.megaAlert addSubview:indicator];
    [indicator release];
}

-(void)dismissMegaAnnoyingPopup
{
    [self.megaAlert dismissWithClickedButtonIndex:0 animated:YES];
    self.megaAlert = nil;
}

You would of course need a UIAlertView *megaAlert; defined in your class.

0

精彩评论

暂无评论...
验证码 换一张
取 消