About adapting to IOS 11 and iPhone x

Time:2021-4-14

preface

As we all know, the official version of IOS 11 has finally arrived. Recently, it has adapted the app. In fact, it’s not very troublesome. Let’s take a look at some of the operations I’ve done. I won’t say much. Let’s have a look.

1. Changes of uitableview and uicollectionview

Self sizing is used by default for tableview in IOS 11. The three height estimation attributes of tableview, estimated row height, estimated section headerheight and estimated section footerheight, have changed from the default 0 to uitableview automatic dimension. So when you pop back, you will find that tableview has moved by itself. Just turn them off. The same is true for collectionview

if (@available(iOS 11.0, *)) {
 tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
 //In fact, just verify the above sentence. The following three sentences are more extreme
 tableView.estimatedRowHeight = 0;
 tableView.estimatedSectionHeaderHeight = 0;
 tableView.estimatedSectionFooterHeight = 0;
}
 
//Swift writing
if #available(iOS 11.0, *) { 
 tableView.contentInsetAdjustmentBehavior = .never 
} else { 
 self.automaticallyAdjustsScrollViewInsets = false 
}

2. IPhone x coming

Because the iPhone x comes out, the screen is too big, there is no home key, and the concept of safearea comes out, which is the safe area to use. So if you use massony, you need to adapt safearea


if (@available(iOS 11.0, *)) {
 make.edges.equalTo()(self.view.safeAreaInsets)
} else {
 make.edges.equalTo()(self.view)
}

In addition, you will find that the tabbar moves up after the iPhone starts. In fact, the startup map is too small. Quickly check IOS 8.0 and later portal, and then put a 3x (1125 * 2436) startup map on it.

Of course, there are many other changes. For example, the status bar and navigation bar are no longer 64, etc. there are many problems. Study slowly.

summary

The above is the whole content of this article, I hope the content of this article has a certain reference value for your study or work, if you have any questions, you can leave a message to exchange, thank you for your support for developer.