IOS8 Uialertcontroller Bullet Box

Source: Internet
Author: User

This article reprinted to http://blog.csdn.net/jinkaiouyang/article/details/35551769

In IOS8, Apple integrates Uiactionsheet and uialertview into one interface Uialertcontroller.

The original is a view, which is displayed on the window view. Now changed to the controller, the display mode becomes by the current controller directly present out.

Here's a look at the specific interface:

[HTML]View Plaincopy
  1. Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "This is Title"
  2. message:@ "This is message"
  3. Preferredstyle:uialertcontrollerstylealert];
  4. [Alert Addaction:[uialertaction actionwithtitle:@ "Action 1 (Default Style)"
  5. Style:uialertactionstyledefault
  6. handler:^ (Uialertaction *action) {
  7. NSLog (@ "Action 1 Handler called");
  8. }]];
  9. [Alert addaction:[uialertaction actionwithtitle:@ "Action 2 (Cancel Style)"
  10. Style:uialertactionstylecancel
  11. handler:^ (Uialertaction *action) {
  12. NSLog (@ "Action 2 Handler called");
  13. }]];
  14. [Alert addaction:[uialertaction actionwithtitle:@ "Action 3 (destructive Style)"
  15. Style:uialertactionstyledestructive
  16. handler:^ (Uialertaction *action) {
  17. NSLog (@ "Action 3 Handler called");
  18. }]];
  19. [Self Presentviewcontroller:alert animated:yes completion:nil];

[HTML]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. <span style="font-family:arial, Helvetica, Sans-serif;" > When generating Uialertcontroller, you can specify a title, a message, or Preferredstyle to specify whether it is alert or </span>  <span style="Color:rgb (61, 29, 129); Font-family:menlo; font-size:14px; " >actionsheet</span>

[OBJC]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. typedef ns_enum (Nsinteger, Uialertcontrollerstyle) {
    2. Uialertcontrollerstyleactionsheet = 0,
    3. Uialertcontrollerstylealert
    4. } ns_enum_available_ios (8_0);

Add specific buttons via the Addaction interface, set the button title, style, and join the button response interface directly using block mode.

Style has the following types:

[OBJC]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. typedef ns_enum (Nsinteger, Uialertactionstyle) {
    2. Uialertactionstyledefault = 0,
    3. Uialertactionstylecancel,
    4. Uialertactionstyledestructive
    5. } ns_enum_available_ios (8_0);


Compared to the original Uiactionsheet and Uialertview:

1, there is no visual change, with the previous style of consistency;

2, change the controller mode, the control life cycle can be better controlled; Easy eject and pick up

3, the current controller POPs Uialertcontroller, again present controller must present on the basis of Uialertcontroller. After the present, the Uialertcontroller will be covered. And the previous uiactionsheet and Uialertview because it is add on the window, when the controller on the basis of the pop-up present controller, The Uiactionsheet and Uialertview bullets remain at the top of the box.

4, modified to controller mode, the interface is more simple, and the button response more concise introduction, do not need to set delegate and implement response callback and so on.

IOS8 Uialertcontroller Bullet Box

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.