Problems with iOS 11 adaptation

Source: Internet
Author: User


Question 1. Custom Uitoolbar, after upgrading to iOS 11, click No response

Reason: IOS11 's uitoolbar adds a Uitoolbarcontentview child control that covers the outermost layer so that the button is added at the bottom, and the click does not respond.

Workaround:

The best way:

after the Uitoolbar is instantiated,

Add

[Toolbar layoutifneeded]; Can. (Pro-Test available)

For example:
Uitoolbar *toolbar = [Uitoolbar new];
[Self addsubview:toolbar];
[Toolbar layoutifneeded];

Add a child view to add

Solution Source:

Https://stackoverflow.com/questions/46107640/ios11-uitoolbar-contentview

Other methods reference: (by adding item)

Uitoolbar, where Rectbutton, Circlebutton have a ButtonClick: method
Uitoolbar *marktoolbar = [[Uitoolbar alloc] Initwithframe:cgrectzero];
Uibarbuttonitem *rectitem = [[Uibarbuttonitem alloc] InitWithCustomView:self.rectButton];
Uibarbuttonitem *circleitem = [[Uibarbuttonitem alloc] InitWithCustomView:self.circleButton];
Uibarbuttonitem *flexibleitem = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem: ( Uibarbuttonsystemitemflexiblespace) target:self Action:nil];
Nsarray *items = @[rectitem,flexibleitem,circleitem];
[Marktoolbar Setitems:items Animated:yes];
Can only be achieved by adding an item

Solution Source:

Http://www.cocoachina.com/bbs/read.php?tid-1725608.html


Question 2. TableView Refresh, the data is loaded, but the position has offset

Reason: Table views: Enable Self-sizing by default in iOS 11

This should be the biggest change in UITableView. We know that after IOS8 introduced the self-sizing, we can display the dynamic content by implementing the Estimatedrowheight-related properties, the Estimatedrowheight attribute is realized, the initial contensize is an estimate , it is through the number of Estimatedrowheight XCell, not the final contensize,tableview will not calculate all the height of the cell, will only calculate the current screen can display the number of cell plus a few, sliding, TableView keeps getting the new cell, updating his contensize, and getting the right contensize at the end of the slide. In the process of creating tableview to display, the Contentsize calculation process is as follows:

Method of solution;

If the Estimaterowheight attribute is not used in the current project, it should be noted in the IOS11 environment, because after the self-sizing is opened, TableView is using the Estimaterowheight attribute. This will result in changes in the value of Contentsize and Contentoffset, if there is animation to observe the changes in these two properties, it will cause the animation of the exception, because in the estimation of the row height mechanism, the contentsize value is a little change in the update, The final contentsize value is when all the cell displays are finished. Because the correct row height is not cached, the contentsize will be recalculated when the TableView reloaddata, which can cause contentoffset changes. If you do not want to use self-sizing under IOS11, you can close it in the following ways:

self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
Problem 3 Solution Source: Author: Sonialiu Link: http://www.jianshu.com/p/370d82ba3939 Source: Jane Book copyright belongs to the author. Commercial reprint please contact the author to obtain authorization, non-commercial reprint please indicate the source.

Related Article

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.