Third, the iOS8 after the window indicator

Source: Internet
Author: User

when users use the app for some risky operations, the use of dialog boxes to prompt users to play a very user-friendly role. The following two types of dialogs are commonly used: Uiactionsheet and Uialertview. But after iOS8 uiactionsheet and uialertview are defined as obsolete, official documentation explains:

Uiactionsheet is deprecated. Use Uialertcontroller with a preferredstyle of Uialertcontrollerstyleactionsheet instead

Here are the basic uses of two common dialog boxes:

//First way

Create a bullet box indicator

Uiactionsheet *sheet = [[Uiactionsheet alloc] initwithtitle:@ "Are you sure you want to cancel?" "Delegate:self cancelbuttontitle:@" Cancel "destructivebuttontitle:@" OK "otherbuttontitles:nil, nil];

Bullet Box Tips

[Sheet Showinview:nil];

Use Uiactionsheet's proxy method for related operations

Proxy methods for #pragma mark-actionsheet

-(void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (Nsinteger) Buttonindex;

{

if (Buttonindex = = 0) {//click OK button

//write code that requires relevant action

}

The second way

Create dialog box

Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:nil message:@ "Pro, are you sure you want to log off? [Preferredstyle:uialertcontrollerstyleactionsheet];

Create Cancel button

Uialertaction *cancelaction = [uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel handler:^ ( Uialertaction *action) {

Related actions

}];

Create OK button

Uialertaction *sureaction = [uialertaction actionwithtitle:@ "OK" style:uialertactionstyledestructive handler:^ ( Uialertaction *action) {

callback method

[Self.navigationcontroller Popviewcontrolleranimated:yes];

}];

Add a button to a dialog box

[Alert addaction:cancelaction];

[Alert addaction:sureaction];

Show dialog box

[Self Presentviewcontroller:alert animated:yes completion:^{

Related actions after completion of display

}];

Third, the iOS8 after the window indicator

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.