Uialertview is what we always call a warning view
Role: Prompts the user to help the user select
There are 2 main forms in iOS 1. Is alert alert pop-up with vibration effect is primarily to give the user a notification
2. Is the Actionsheet will slide out at the bottom of the screen equivalent to produce a screen 1/3 size of the view
This window allows you to publish information to resources such as meager people.
Actionsheet and Alertview are similar to the user a hint message. It is ejected from the bottom. It is usually used to confirm the dive
In the dangerous or cannot undo operation, such as deleting a data.
The action sheet in the iOS program is like the OK-Cancel dialog box in Windows to force the user to make a selection. When a user is about to take a risk, the action sheet is often used to prompt the user for danger, so that the user has the opportunity to cancel the operation.
Action sheet requires multiple parameters:
(1) Initwithtitle: Sets the title, which will be displayed at the top of the action sheet
(2) Delegate: Sets the delegate for the action sheet. When a button of action sheet is pressed, its delegate will be notified, and the Actionsheet:diddismisswithbuttonindex method that will execute the delegate will execute. Here, we set the delegate to self, which guarantees the execution of our own Actionsheet:diddismisswithbuttonindex method written in viewcontroller.m.
(3) Cancelbuttontitle: Sets the title of the Cancel button, which will be displayed at the bottom of action sheet
(4) Destructivebuttontitle: Set the title of the first OK button, which can be understood as: "OK, continue"
(5) Otherbuttontitles: can set any number of OK button
Alert is equivalent to the MessageBox in Windows and is similar to action sheet. The difference is that alert can have only one selection, and action sheet has at least two options.
Alert also needs to fill in a number of parameters:
(1) Initwithtitle: Set the title, will be displayed at the top of alert
(2) Message: Set the content of the prompt message
(3) Delegate: Sets the delegate for alert. Here, we set it to self.
(4) Cancelbuttontitle: Set the title of the Cancel button
(5) Otherbuttontitles: Similar to action sheet
[Alert show] This statement is used to display alert.
Project:uialertorsheetdemo
New file ...
Name:alertview
Superclass:uialertview
Open ALERTVIEW.M
Join
-(void) dealloc
{
NSLog (@ "dead:%d", self.tag);
[Super Dealloc];
}
Open APPDELEGATE.M
Join
#import "AlertView.h"
In-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
In the [Self.window makekeyandvisible]; Top Join
UIButton *button1 = [UIButton buttonwithtype:uibuttontyperoundedrect];
Button1.frame = CGRectMake (10, 100, 140, 40);
[Button1 settitle:@ "Alertview" forstate:uicontrolstatenormal];
[Button1 addtarget:self Action: @selector (Showalertview) forcontrolevents:uicontroleventtouchupinside];
[Self.window Addsubview:button1];
UIButton *button2 = [UIButton buttonwithtype:uibuttontyperoundedrect];
Button2.frame = CGRectMake (240-70, 100, 140, 40);
[Button2 settitle:@ "Actionsheet" forstate:uicontrolstatenormal];
[Button2 addtarget:self Action: @selector (Showactionview) forcontrolevents:uicontroleventtouchupinside];
[Self.window Addsubview:button2];
In the Join method
-(void) Showalertview
{//The first is a Cancel button after the OK button
Uialertview *alertview = [[Uialertview alloc] initwithtitle:@ "title" message:@ "message" Delegate:nil Cancelbuttontitle : @ "Cancel" otherbuttontitles:@ "Other1", @ "Other2", nil];
[Alertview show];
}
-(void) Showactionview
{
Uiactionsheet *actionsheet = [[Uiactionsheet alloc] initwithtitle:@ "title" Delegate:self cancelbuttontitle:@ "Cancel" destructivebuttontitle:@ "destructive" otherbuttontitles:@ "Other1", @ "Other2", @ "Other3", @ "Other3", nil];
[Actionsheet ShowInView:self.window];
}
Uialertview of iOS controls