Uialertview, Uiactionsheet compatible iOS8

Source: Internet
Author: User

Link Address: http://blog.csdn.net/nextstudio/article/details/39959895?utm_source=tuicool1, Preface IOS8 added Uialertcontroller to replace the use of Uialertview, Uiactionsheet. In this paper, without the use of uialertcontroller, the simplest way to make Uialertview, Uiactionsheet compatible iOS8. 2, UIAlertViewiOS8, if the Uialertview initialization when the title is nil, iOS8 the following box in the message will be bold, and too close to the top, in order to save the same version as before IOS8, You only need to set the title to @ "at initialization time. The code is as follows:[OBJC]View Plaincopy
    1. The title is @ "" compatible with IOS8
    2. Uialertview *delalert = [[[Uialertview alloc] initwithtitle:@ "" message:@ "Delete a contact? " delegate:self cancelbuttontitle:@" Cancel " otherbuttontitles:@" Confirm ", Nil Nil]  Autorelease];
    3. [Delalert show];

3, UIActionSheetiOS8, if Uiactionsheet initialization when the title is @ "", iOS8 below the Actionsheet form above will be more than a row of blank bar, in order to save the version of the same as before IOS8, You only need to set the title to nil at initialization time. The code is as follows:[OBJC]View Plaincopy
  1. Uiactionsheet *actionsheet = [[[Uiactionsheet alloc] initwithtitle: nil
  2. delegate: Self
  3.                                                         cancelbuttontitle:nslocalizedstring (@ "Cancel",  nil)   
  4.                                                    Destructivebuttontitle:[nsstring stringwithformat:nslocalizedstring ( @ "call",  nil), self .PHONENUMBER]  
  5. otherbuttontitles:nslocalizedstring (@ "Add to contact", nil),Nil]
  6. Autorelease];
  7. Actionsheet. Tag = 1;
  8. [Actionsheet Showinview:self. view];

Uialertview, Uiactionsheet compatible iOS8

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.