| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iPhone OS 2.0 and later. |
| Declared in | UIAlert.h |
| Related sample code |
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.
– addButtonWithTitle:
numberOfButtons property
– buttonTitleAtIndex:
cancelButtonIndex property
firstOtherButtonIndex property
For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.
The index number of the cancel button.
@property(nonatomic) NSInteger cancelButtonIndex
The button indices start at 0. If -1, then the index is not set.
UIAlert.hThe receiver’s delegate or nil if it doesn’t have a delegate.
@property(nonatomic, assign) id delegate
See UIAlertViewDelegate Protocol Reference for the methods this delegate should implement.
UIAlert.hThe index of the first other button. (read-only)
@property(nonatomic, readonly) NSInteger firstOtherButtonIndex
The button indices start at 0. If -1, then the index is not set. This property is ignored if there are no other buttons. The default value is -1.
UIAlert.hDescriptive text that provides more details than the title.
@property(nonatomic, copy) NSString *message
UIAlert.hThe number of buttons on the alert view. (read-only)
@property(nonatomic, readonly) NSInteger numberOfButtons
UIAlert.hThe string that appears in the receiver’s title bar.
@property(nonatomic, copy) NSString *title
UIAlert.hA Boolean value that indicates whether the receiver is displayed. (read-only)
@property(nonatomic, readonly, getter=isVisible) BOOL visible
If YES, the receiver is displayed; otherwise, NO.
UIAlert.hAdds a button to the receiver with the given title.
- (NSInteger)addButtonWithTitle:(NSString *)title
The title of the new button.
The index of the new button. Button indices start at 0 and increase in the order they are added.
UIAlert.hReturns the title of the button at the given index.
- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex
The index of the button. The button indices start at 0.
The title of the button specified by index buttonIndex.
UIAlert.hDismisses the receiver, optionally with animation.
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
The index of the button that was clicked just before invoking this method. The button indices start at 0.
YES if the receiver should be removed by animating it first; otherwise, NO if it should be removed immediately with no animation.
UIAlert.hConvenience method for initializing an alert view.
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
The string that appears in the receiver’s title bar.
Descriptive text that provides more details than the title.
The receiver’s delegate or nil if it doesn’t have a delegate.
The title of the cancel button or nil if there is no cancel button.
Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title.
The title of another button.
Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons.
Titles of additional buttons to add to the receiver, terminated with nil.
Newly initialized alert view.
UIAlert.hDisplays the receiver using animation.
- (void)show
UIAlert.hLast updated: 2009-04-30