Difference between iPhone simulator and iPhone - ios

I'm building a iOS app for iPhone. I'm using a collection view, to display a supplementary view. The collection view is in a view controller with a navigation controller. I've created the supplementary view in as xib, using autolayout and constraints.
I've set the navigation controller to be invisible:
navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
navigationController!.navigationBar.shadowImage = UIImage()
navigationController!.navigationBar.translucent = true
When I run the app on my device (iPhone 6) I see this:
When I run the app on the simulator (iPhone 6) I see this:
So it seems that the view gets a different layout on the simulator. On the simulator the "top space to superview" constraint sees the bottom of the invisible navigation bar as the frame of the superview. Whereas on the actual device, it seen the actual view controller frame as the superview.
How come the differens? Which one should be trusted?
Image of top constraint of the supplementary view:

Related

Stack layout doesn't reflect on the simulator properly

Here, I tried to show two labels on the screen in table view cell using stack view But When I run it on the simulator it does appear on the screen as it is designed on the storyboard (leading space does not reflect on the simulator).
StoryBoard
Simulator

UISearch layout is different on different iPhones

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)

iPhone X custom tab bar issue

We have custom tab bar in our app. The height of the custom tab bar is fixed. It was working fine for all devices except iPhone X. The problem is the height of custom tab bar is 45 but in iPhone X it will collide with the home indicator. So we had changed the bottom of the custom tab bar to the safe area. But the problem will be I will see the background view below my custom Tab bar. My question how can we give constraints to Custom tab bar that will be same height all devices except iPhone X and also hides the bottom space in iPhone X? but I want to increase the height of tab bar in iPhone X but I shouldn't affect other devices. Btw I don't want to write a code to separate iPhone X and other devices. All I want to do it in storyboard itself.
How about this?
set your view to be within safe area
set fixed height to your custom tab bar
put a view and set margin between safe area bottom and superview bottom
refer to the picture below
Constraints
How it looks like on iPhone X
How it looks like on other iPhone
How about making a view effect view at the bottom, which is larger than 44pt? I have tried it in my application and it works well.
refer: https://novemberfive.co/blog/apple-september-event-iphonex-apps/
Hope this helps you with programmatically
self.tabBar.layer.masksToBounds = true
self.tabBar.isTranslucent = true
self.tabBar.barStyle = .blackOpaque
self.tabBar.layer.cornerRadius = 20
self.tabBar.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]

View under my container view is not showing up on iOS device

I currently have a UIContainerView and a UIView in a view controller, the container view is at the top and the view is at the bottom, it is a small rectangle in which I will put a banner ad. I have constrained both of these things in my view controller but when run the view at the bottom does not show. Below is the Storyboard and the iPhone 5s it is running on.
Here is my device, as you can see it only shows my container view (which has a table view in it), and it does not show the purple view below it:
Here is my storyboard:
Here are my constraints on my view controller:
You should remove View.top = top + 617 constraint and that would fix it.

XCode 7 and iOS 8 Auto Layout top constraint issue

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.

Resources