How to use Ios--uialertview details
Common methods of Uialertview
Standard Style
Uialertview *onealertview = [[Uialertview alloc] initwithtitle:@ "title" message:@ "Prompt content" delegate:self cancelbuttontitle:@ "Off" otherbuttontitles:@ "OK", nil];
[Onealertview show]; Show up
[Onealertview release], Onealertview = nil; Freeing memory
Onealertview.alertviewstyle = Uialertviewstyledefault; Set the style of Onealerview
Uialertviewstyledefault Only Information and buttons
Uialertviewstylesecuretextinput has a TextField encryption box
Uialertviewstyleplaintextinput has a non-encrypted TextField
Uialertviewstyleloginandpasswordinput has two textfield,login and password
Button Horizontal Display
Uialertview *twoalertview = [[Uialertview alloc] initwithtitle:@ "title" message:@ "Prompt content" delegate:self cancelbuttontitle:@ "Off" otherbuttontitles:@ "button 1", @ "button 2", @ "button 2", nil];
[Twoalertview show]; Show up
[Twoalertview release], Twoalertview = nil; Freeing memory
With multiple buttons added, how do you know which button we're pressing?
You need to implement the Uialertviewdelegate proxy in the. h file, and then override the following method in the. m file
#pragma mark-Implement Uialertview proxy method to determine which button was pressed
-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) Buttonindex {
Get which button you pressed
nsstring* msg = [[NSString alloc] initwithformat:@ "You press the%d button! ", Buttonindex];
NSLog (@ "%@", msg);
[MSG release], msg = nil;
Click "Cancel", "button 1", "button 2", "button 3" index Buttonindex respectively is 0,1,2,3
}
Add Additional to Uialertview
Uialertview*alert = [[Uialertview alloc]initwithtitle:@ "Please Wait"
Message:nil
Delegate:nil
Cancelbuttontitle:nil
Otherbuttontitles:nil];
[Alert show];
Uiactivityindicatorview *activeview = [[Uiactivityindicatorviewalloc]initwithactivityindicatorstyle: Uiactivityindicatorviewstylewhitelarge];
Activeview.center = Cgpointmake (alert.bounds.size.width/2.0f, alert.bounds.size.height-40.0f);
[ActiveView startanimating];
[Alert Addsubview:activeview];
[ActiveView release];
[Alert release];
There are many ways to get a deeper look at the API itself and try it out slowly. These are basically enough ...
How to use Ios--uialertview details