简体   繁体   中英

Back button in NavigationBar move down after rotate back to portrait in iOS11

When I rotate the screen to Landscape and then rotate back to Portrait the back button drop down somehow like this.

在此处输入图片说明

the original is this. 在此处输入图片说明

not only the title of back button but also the image drop down. I tried to set the frame by the back button's frame before rotation but it's not working. I'm sure the custom image of the back button is irrelevant.

The wired thing is I open an new testing project to reproduce the situation but it work perfectly. I checked every setting in Navigation Controller from storyboard

在此处输入图片说明

or setting in Navigation Bar

在此处输入图片说明

They are all the same with my original project. What do I missing?

This drop down only occur in iOS11.

Could it be the bug of iOS11?

Please help. THX

ps I'm using Xcode9.2

It seems that calling setNeedsLayout() (as suggested here ) works.

override func viewDidLayoutSubviews() {
    navigationController?.navigationBar.setNeedsLayout()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM