How to use Ios--uialertview details

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.