How to remedy a UINavigationBar overlapping the to

2019-08-24 06:36发布

I am working with a TabBarController >> NavBarController UI. One of my UIViewControllers has a UIScrollView in it with some text (UITextField) in it. Problem is, the uppermost text in the UIScrollView is covered by the NavBar. How do I fix this? I am trying to manually adjust stuff in IB with mixed results but I want a more CERTAIN solution.

1条回答
成全新的幸福
2楼-- · 2019-08-24 07:17

The problem is that your view is too big, and it's being positioned under the nav bar.

To fix, open up the .xib with your container view and/or your UIScrollView in Interface Builder, and Bring up the Attributes Inspector (Cmd-1).

Then do one of the following:

  1. Make sure the Simulated User Interface Elements (for Status Bar, Top Bar, and BottomBar) are set to appropriate values (which will automatically adjust the subview frames)

or

  1. Set all Simulated User Interface Elements None, and then size your container view down to an appropriate size (like 320x400), set the autosizing to expand in both directions. (I prefer this method, and this is also the default method for a nav bar-based project that Xcode autogenerates)

Then you need to make sure that you've set the root view controller for that tab to "Resize View from NIB". If you've instantiated a UINavigationController instance in Interface Builder (say, in your MainWindow.xib), you can set the checkbox there.

查看更多
登录 后发表回答