About using the prompt box in iOS

Source: Internet
Author: User

About using the prompt box in iOS
In IOS8 's SDK, the prompt box has been changed, now belongs to Uialertcontroller, and its interface is declared Ns_class_available_ios (8_0) @interface Uialertcontroller: Uiviewcontroller, is no longer a uiview.

The specific use of the following, I hope to help some friends.
#if __iphone_os_version_max_allowed >= __iphone_8_0//Determine the maximum iOS system version supported by your current iOS SDK
if (systermversion >= 8.0) {
Uialertcontroller *ALERTVC = [Uialertcontroller alertcontrollerwithtitle:@ "hint" message:@ "This is the use of the warning box above the iOS8.0 version" Preferredstyle:uialertcontrollerstylealert]; Select whether it is alert or sheet through the Preferredstyle parameter.

Uialertaction *sureaction = [uialertaction actionwithtitle:@ "OK" Style:uialertactionstyledefault handler:^ ( Uialertaction *alertaction) {
When the button is clicked, the response is no longer handled by the agent, but by the black body callback
NSLog (@ "OK button is clicked, Test succeeded");
}];

Uialertaction *cancelaction = [uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel handler:^ ( Uialertaction *alertaction) {
NSLog (@ "Cancel button was clicked, Test succeeded");
}];

[ALERTVC addaction:sureaction];
[ALERTVC addaction:cancelaction];

[Self PRESENTVIEWCONTROLLER:ALERTVC animated:yes completion:^{nslog (@ "jump success");}];
}
Else
{
Uialertview *alert = [[Uialertview alloc]initwithtitle:@] Prompt "message:@" This is the use of the following warning boxes for iOS8.0 versions "delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
[Alert show];
}
#else
{
Uialertview *alert = [[Uialertview alloc]initwithtitle:@] Prompt "message:@" This is the use of the following warning boxes for iOS8.0 versions "delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
[Alert show];
}
#endif

}

About using the prompt box in iOS

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.