Showing a pop-up dialog on an iPad
I would like to show a pop-up dialog to notify a user that server data is being accessed from an iPad app, specifically over top of a split view controller. Is the best way to do this with a separate controller that is 开发者_Python百科presented modally? The view controller guide indicates that modal view controllers are full screen transitions, so not used often in iPad apps, so I'm wondering if there is a better approach, since I would simply want to create a semi transparent background with the activity indicator and message.
I don't want to just use one of the split view's two controllers, however, because it doesn't seem the right approach.
You could do that with an UIAlertView.
UIAlertView *alert;
...
alert = [[[UIAlertView alloc] initWithTitle:@"Accessing Data..."
message:nil delegate:self cancelButtonTitle:"Cancel" otherButtonTitles: nil] autorelease];
[alert show];
HERE they discuss setting it with no buttons so you can control when you want to dismiss it (in case you are trying to prevent the user from interacting while that server data is being accessed). Basically you end up with:
UIAlertView *alert;
...
alert = [[[UIAlertView alloc] initWithTitle:@"Accessing Data..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[alert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
[indicator release];
which is an alert view with activity indicator inside, which you can dismiss with:
[alert dismissWithClickedButtonIndex:0 animated:YES];
Hope that helps.
精彩评论