收录日期:2019/09/19 00:20:37 时间:2008-12-08 09:44:36 标签:iphone,cocoa-touch

Does anyone have any best practices, tips & tricks, or recommendations for how to create modal Alert Views with Cocoa Touch?

I like to think there is a way to make this difficult task trivial or at least easier.

You can use something like this:

void AlertWithMessage(NSString *message)
{
/* open an alert with an OK button */
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Name of the Application" 
								message:message
							    delegate:nil 
								cancelButtonTitle:@"OK" 
							    otherButtonTitles: nil];
[alert show];
[alert release];
}

I just use UIAlertView to display modal alerts. What additional functionality are you looking for?

Check out the UICatalog sample code from Apple. It shows the usage of both Alerts and Sheets on the phone.