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
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
#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];
How to use Uialertview