Solution to uibarbuttonitem Migration under IOS7

Source: Internet
Author: User

IOS7 under the Uibarbuttonitem offset 10pt, I believe this is the effect that we do not want, the solution is to add a uibarbuttonsystemitemfixedspace item, But at 7.1 start, just add a fixedspaceitem run will hang off, swollen, compatible solution is to add an empty item in front, the code is as follows:


Uibarbuttonitem *item = [[uibarbuttonitem alloc] initwithcustomview: button]; Item to add to the Navgationbar


if ([uidevice iOS7]) {

        uibarbuttonitem *plain = [[ Uibarbuttonitem alloc] initwithtitle: span class= "s2" >nil style: Uibarbuttonitemstyleplain target: nil action< Span class= "S1" >: null ];    //Resolve 7.1 hang-out issues

uibarbuttonitem *fix = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem :uibarbuttonsystemitemfixedspace target : nil action : NULL ];

Fix.    width =-ten; Correcting offsets of 10pt

self. Navigationitem.    Rightbarbuttonitems = @[plain,item,fix]; That's it, perfect!

} Else {

self. Navigationitem. Rightbarbuttonitem = Item;

}


This article is from the "idanal" blog, make sure to keep this source http://danal.blog.51cto.com/3353275/1565509

Solution to uibarbuttonitem Migration under IOS7

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.