views:

2207

answers:

3

I'm looking for the class name of the popup/message windows on the iPhone (it's a blueish window that comes up when you have a missed call, or a message comes in for example.)

+6  A: 

The class is called "UIAlertView." From the documentation:

Use the UIAlertView class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of UIActionSheet).

Use the properties and methods defined in this class to set the title, message, and delegate of an alert view and configure the buttons. You must set a delegate if you add custom buttons. The delegate should conform to the UIAlertViewDelegate protocol. Use the show method to display an alert view once it is configured.

lajos
Keep in mind that this is modal on the UI, but not in the code. The show method will return immediately but the dialog will be managed in the current run loop. This means that you won't know the results right away.
Darron
A: 

The examples you gave (missed call or incoming text message) are system level alerts that pop up over any application. That functionality is not available through the SDK. lajos's answer does provide the correct way to display an alert, but it is worth remembering you can only do this within your application. You cannot pop up an alert over another app because the SDK currently prohibits an app from running in the background.

benzado
+1  A: 

Further to this response, UIAlertView is indeed the way to do this and the code you want is:

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Message" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];

[alert show];

Here the alert box will popup with the message "Message" and have a single button titled "OK" which will close the popup when clicked. Check the documentation for other things you can do (more buttons etc).

DavidM