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)
Related
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 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.
I have a problem with a "double" navigation bar in a screen of my iPhone app.
Starting position:
Xcode 8, Swift
I have a TableView with static lines that is embedded in a navigation controller. From the first cell I then call a screen (Segue Show Detail), which is very complex (labels, text boxes, buttons, etc.). When I execute the "Reset to suggested constraints" function on the screen, the screen is supplied with "generated" constraints. This is still clear. When I run my app in the simulator (iPhone 6) or my own iPhone 6, I see on the above screen a status bar, then my right navigation bar (Back button, title) and below an "empty" 2.Navigation bar. This decreases the screen down and is no longer fully visible. If I delete the constraints for the screen with the "Clear Constraints" function, the screen in the simulator (i6) looks good as I develop in the storyboard for the iPhone 7. But when I connect my own iPhone 6 and test, the screen does not fit completely to my iPhone, because right and down is something truncated.
I suspect the error in the "generated" constraints.
Now my question:
How can I check the generated Contraints (well over 100) for errors?
In the Internet and the forum I found nothing, which could help me.
Workaround for me:
The top UI element on the screen is a label across the entire width of the screen. For this label, I set a constraint manually, in addition to the generated constraints
Label.top = Top Layout Guide.bottom + 44,
whose value I then change to the value
Label.top = Top Layout Guide.bottom
This causes the label to slide directly below the status bar in the storyboard. The navigation bar is then no longer visible in the storyboard. This makes the placement of UI-Elements at the bottom of the screen somewhat more difficult because you do not know exactly which space is still available.
The display in the simulator (i6) and on my iPhone 6 looks however through the workaround ok.
For your help I would be very grateful.
Greeting Reinhard
I have a UIToolbar with a button in it. In the storyboard everything looks fine. The problem is when I run it on the simulator it doesn't look the same as on the storyboard.
(Note: It won't even let me add constraints to the button.)
In storyboard:
In simulator:
Bar button items do not size automatically, and the size you have set is for 4 inch and below device, because this is the default size in storyboards. However, you are running on an iPhone 6 simulator, thus the screen is wider, and the button does not fill the entire bar.
If you need to have the button fill the entire bar, you will have to do it in code, in viewDidLayout, changing the bar button item's width to that of the bar.
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