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.
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 am following this tutorial, and as shown in image-1 below, I added the "Add" bar button, but when I run the simulator it does not show up as shown in image-2.
please let me know why the "Add" button is not showing and how to fix it.
image-1:
image-2:
Two possible scenario :
Scene 1 :
Looks like you are using iPhone 6s Plus simulator and 100% zoomed. So I could see horizontal and vertical scroll both. I believe the Plus button is still there its just that u have to scroll to see it. Even the title Players is not in center :)
Use Command + 3 to zoom out the simulator and see the O/P without scroll :D
Scene 2:
If you have added Navigation bar manually make sure you add top, leading and trailing constraint to Navigation Bar. The Nav bar you added is bigger than iPhone 6 plus size and because there is no auto layout constraint added it might have extended beyond the screen.
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 am trying to display some UIView (say, UIButton or UITextView) right below the top of the screen. I do not use IB nor autolayouts: I am trying to do it manually. I have my status bar disabled, hence my applicationFrame == bounds of default screen.
My UIView's frame.origin.y is 0.
On IPhone4 and IPad (emulation) it works correctly: I see my element in the left top corner. But when I set emulator to IPhone5 the element is is not displayed (actually, it is displayed above the screen). When I set its y to about 50 it is displayed correctly.
Is it an emulation bug or something worng with my code?
What version of iOS is the iPhone 4 running?, if its 6 or lower then it will display it correctly.
From iOS 7 and above you have to add the topLayoutGuide to the frame.origin.y of a view if you want it to be below the status bar. Im sure your simulator is running iOS 8, thats why it doesnt display right there.
I just found that status bar (the one with battery indicator) is not displayed in IPhone5 emulator even if I turn it on ("status bar is initially hidden == NO"). I scrolled my emulator and found bar and my UIView! For some reason IPhone5 (but not Iphone4 nor IPad!) emulator starts with screen scrolled. Probably I created view to big to fit the screen (which is strange because applicationFrame is used).
The bottom strip of my view in storyboard is not displaying on the iPad. I am not sure if it is not being drawn or if the view on Storyboard is too big.
UILabel is not hidden
Changing color of text has no effect
Everything else appears without issue
In the Attributes Inspector, I have size set to iPad Full Screen
Bottom Strip in Storyboard:
Bottom Strip on Simulator:
This is likely either a tab bar or a navigation bar that is not being accounted for. These can be simulated on IB via the attributes pane on the view controller you're working with.