I recently migrated an App to Swift 4 and iOS 11 and noticed a very strange issue on iPads running iOS 10. When the UISearchController is presented, the UITableView gets a -20px offset making it partly covered by the search bar.
My view controller structure is UISplitViewController -> UINavigationController -> UIViewController. The UIViewController has only one view which is a UITableView. The UISearchController is added via code and the UISearchBar is added to the tableviews tableHeaderView.
On iPhone, its working perfectly fine and iOS 11 is also working like a charme. It's only happening on iOS 10 on iPad.
Try to set top space constraint to Top Layout Guide, not to superview.
Select Table View:
Size inspector, select Top constraint, double-click on it, change constraint item from Superview to Top Layout Guide.
Related
On my storyboard, I add a UISearchBar and below that I added a table view. On iPhone 8, I am seeing the UISearchBar right below the navigation bar/header and on iPhone 5s and on iPad and I seeing some space between navigation bar/header and the UISearchBar.
Image showing iPhone 5s on left and iPhone 8 on right:
UISearchBar on ViewController on the storyboard
UITableView on ViewController on the storyboard
Constraints on that view
Any idea what could be happening?
EDIT:
I tried wrapping up both search bar and table view in UIStackView and added constraints around UIStackView so I don't have to add constraints for search bar and table view, but this time the search bar doesn't show up at all on the screen.
Screen with UIStackView
Did you check it without UITableView?
Maybe it changes its position only seemingly?
Go to simulator -> window -> unmark 'show device bezels' and add 'pixel accurate' ( cmd + 2)
I have a UIViewController that contains a UISegmentControl at the top, and a UITableView below. The layout is very simple. The UISegmentControl Top Margin is 16pts from the Top Layout Guide. The tableView is relative to the UISegmentControl. The view is part of a UITabBarController set. The UITabBarController is the storyboard's initial view controller.
I'm experiencing a problem where, on iOS 9 and 10, the UISegmentControl and the UITableView are positioned too high at initial app launch. As a result the UISegmentControl is partially obscured. If I switch to another tab or the next view in the hierarchy (by tapping a table cell), then go back to this view, the problem resolves itself.
The problem does not occur on iOS 11. The app doesn't support anything earlier than iOS 9.
Here are screenshots, taken both immediate after launch and then after switching to another tab then back again. Any suggestions appreciated.
Turn off extend edges under top bar :
Check your view controller attributes inspector in IB. Look for
"Extend Edges" option under View Controller, and uncheck "Under Top
Bars" if it is checked.
I recently updated my XCode 6.3 to 7 and strange things started to happen with my auto layout constraints in the storyboard.
My app uses UITabBarController with three tabs. The initial tab has a UICollectionView with top constraint set to 44px from the top layout guide (there is a toolbar in the embedding UINavigationController.
When I run the app on iOS 7.1 (iPhone 4), everything looks fine. The collection view doesn't go bellow the toolbar. However in iOS 8.4 (iPhone 6) the collection view goes bellow the toolbar UNLESS I switch tabs and go back to the first one, where the collection view is positioned where it should be.
What I did:
Unchecked all "Extend edges under...." for every view controller in the chain
Set all simulated metrics for Status/Top/Bottom bars to "None" in every view controller in the chain
I had the idea to check for #available(iOS 8.0, *) and extend the constraint constant +20 pixels. But when I switch back to this tab, the collection view goes 20 pixels lower than where it should be.
So, I guess something happens to the view controllers when I switch tabs. What is it? Or is there any solution. I'm on a deadline and this is the only problem I have with my app.
p.s. I can provide source code and XCode screen shots if needed. But still, I think it's something more theoretical, than practical.
1) click on your UITabBarController in storyboard->identity inspector
2) uncheck "Adjust Scroll View Insets"
repeat for individual view controllers inside UITabBarController
Sometimes this happen also to me. I suggest replacing the top layout constraint with an height constraint equal to the view of the ViewController, this resolved my problem.
I'm making UIViewController with UITableView on it. I would like this tableview to act like "Notes" default app (when you scroll table content is blurred under nav bar).
As far as I understand I must put my tableView BELOW Top Layout Guide. If I do it, content don't go under nav bar (because top layout guide is below nav bar).
If I put tableView above Top Layout Guide content "blurred" under nav bar and first table is hidden, and on iOs6 is upper part of tableview is hidden.
Should I manually set content offset based on iOS version? I can't use self.topLayoutGuide inside viewController as it was introduced only in iOs7.
View hierarchy
UINavigationController -> UiViewController
\
- UIView
\
- UITableView
Everything is built in storyboard
Since you are targeting more than OS version, then I think you should handle your UI depending on the OS version.
So, yes, I do recommend setting self.topLayoutGuide within your code depending on the OS version.
I am trying to add a UITableView (TV) as a subview in one of my xibs, and this TV include a SearchBar at the top. After I have setup my xib so it looks correct I try running the simulator, however the TV seems to be leaving a gap at the top to allow for the UINavigationBar (see screenshots below):
Can anyone advise me on how to overcome this issue, I am running in to a lot of issues in Xcode 5 which I did not have before when setting up nibs.
Thanks for any help.
If you use storyboard and drag a tableview inside an UIView embedded inside a Navigation controller Xcode automatically considers the space for the navigation bar.
if not add constraints. for a tableview you need 4 constraints:
Leading
Trailing
Top space
Bottom space
to add constraints select the tableview and go to editor->pin and select them