I am using Xcode 7 GM version to test my app for iOS9.
My app works find on iOS 8 & 7, while I am testing my app on iOS9 simulator, I find my view size is not correct. I setup my view controller in xib, using autolayout and size class. I only support portrait mode, so all of my constraints are only installed in w:compact, h:regular.
After debugging using Reveal, I found that, the self.view, a UIViewController of mine, embedded in UINavigationController, is always 600*600 size and never changed after autolayout.
I see there is constraint height:600, width:600 for self.view, but I never explicitly specify them. The point is why iOS 9 is behavining like this and how do I fix it? Thanks.
The self.view is like the root view and I got no chance to set autolayout for it. No idea why it is always and never changed.
Screen shot:
First, in portrait mode the size class of height is regular on any iPhone. Second, it's recommended to use size class Any as a starting point, then adjust them if you want different layout for a specific size class.
Related
I have some troubles with the LaunchScreen.storyboard.
My app is a Universal App, default orientation is portrait but landscape is also allowed.
My LaunchScreen is very simple.
A UILabel with 2 constraints :
Align leading to Safe Area (with constant = 30)
Top space to Safe Area (with constant = 30)
When I check my LaunchScreen inside XCode with simulated traits (iPhone XR, iPad, Landscape, Portrait…) everything looks fine.
When I launch the app in portrait orientation everything looks fine.
Then I turn the simulator (or real device) to landscape and re-run the app.
This time the UILabel doesn't respect it's constraints. The label is touching the black notch and the top space seems twice the defined size.
Do you have the same problem ? How can I fix it ?
Apple describes this in their documentation as follows:
At launch time, apps should always set up their interface in a portrait orientation. After the application(_:didFinishLaunchingWithOptions:) method returns, the app uses the view controller rotation mechanism described above to rotate the views to the appropriate orientation prior to showing the window.
So I believe the behaviour you're after isn't particularly supported by Apple I'm afraid. As a side note, I'm not entirely sure how they support it on iPads.
Apply constraints to your UILabel as per my below screenshot :-
Also, in your project Target set Deployment Info :-
If you want to change UILabel frame, then ask me.
I am currently developing an iOS 10 app using XCode 8. But for some reasons on all devices the view bounds are 1024x768 pixels. I googled around very much, found some informations about launch screen images. I added them in the correct resolutions, etc. Created app icons in the right resolutions but it does not work.
Am I missing some settings that it runs on an iPad Pro with full resolution? The project is configured as universal.
Thanks in advance!
It's iOS 10 new features. Now all views has 1000x1000 frames after viewDidLoad. You can check this in UIViewController's viewDidLoad method. (all but self.view, it still has values from xib/storyboard file).
If your constraints is correct, you can get values in viewDidLayoutSubviews. I mean this is there you need to check view size.
I want to describe an issue (and its corresponding solution) I was having with Size Classes.
For a UIViewController and iPhone-only environment, I want to have a different layout for landscape and portrait. I have the corresponding designs on Interface Builder using Size Classes. However, when running the application on the simulator, I always get the portrait layout regardless of the device orientation.
I have tried 2 different approaches:
Creating the portrait layout for the Any-Any Size Class and the landscape one for wAny-hCompact.
Creating the portrait layout for the wCompact-hRegular, the landscape one for wAny-hCompact and a different one for Any-Any.
In both cases, everything looks good in the Preview feature of Interface Builder for all iPhone devices and orientations but on the simulator I always see the portrait layout regardless of device orientation.
I am using Xcode 7.2 and I have tried all iPhone Simulators on both iOS 8.4 and 9.2. No warnings about autolayout constraints are seen on any of the Size Classes.
The problem turned out to be unrelated to the usage of Size Classes. I didn’t notice I was getting this warning when presenting the problematic view controller: Presenting view controllers on detached view controllers is discouraged
Fixing that issue and removing that warning made everything work as expected.
Hi I am facing a strange issue. I am adding a UIViewController to Window's RootViewController.
I have set my ViewControllerXIB's autoresizing as MaskAll. When I run my project on iPad with iOS 7 in Landscape mode, I get screen size as (1024,768). But when I run on iPad with iOS 8, I get the screen size as (768,1024). I am not able to figure it out why this is happening. Due to this my ViewController's subviews are not loading with proper screen size since I am passing them the ViewController's screen size.
Can anybody help me out on this?
But when I run on iPad with iOS 8, I get the screen size as (768,1024).
It's because in iOS 7 and before, app rotation involves applying a rotation transform to the root view controller's view, while the window and screen remain pinned to the device. But in iOS 8, the entire app literally rotates. This is a major change and it can indeed break your existing code if you were expecting the rotation transform. On the other hand it's also much better - in iOS 8, rotation means that the screen, the window, the root view controller's view all simply change size (they swap their height and width) - and that means that if your app launches into landscape it has the correct dimensions right from the start.
If you need pure device coordinates in iOS 8 you can get them with the new UICoordinateSpace protocol (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICoordinateSpace_protocol/).
I am experience a rendering bug when using the default progress view. Rather than being 9px tall, the view is clipped to about 4px when using the default progress view. My app is built with the iOS6 SDK, and the issue appear when running on a iOS7 device. The interface is built with interface builder.
Is there a simple fix for this issue? Switching the style from "Default" to "Bar" in interface builder fixes the problem, but that changes the appearance.
Setting the frame in code helped me solve this.
#iPP 's answer is not the best. Setting the frame in code will cause your code to be riddled with iOS version checks, and that code tends to get very complicated when supporting multiple device orientations.
I think the best way is to use new feature "iOS 6/7 Deltas" in Xcode 5.
And "iOS 6/7 Deltas" key usage is:
When Auto Layout is turned off, you will notice an area in the sizing tab of the utility area (right pane) of Interface Builder that allows you to set iOS 6/7 Deltas. Deltas can be set individually for each view and work as you would expect. If your storyboard or nib is set to view as iOS 6, then setting the deltas will cause that view to be shifted and/or resized by the set delta amount when run in iOS 7. Alternately, if your storyboard or nib is set to view in iOS 7, then the deltas will be applied when run in iOS 6. Both of these tools help you to support older versions of iOS alongside iOS 7
for UIProgressView, here you can try to set "delta Y" to be -7px, because iOS 7 just reduce the Y origin of UIProgressView by 7 px, so when running in iOS7, we should give it back the 7px.
It's like the iOS7 cut the progress view use the iOS7 Style's frame.
You have two ways.
1. set the progress view style ---bar, you can do this in the nib file or code.
2. use the code to set the frame. Something like:
progressView.frame = CGRectMake(x,y,w,h);
The second will face the layout issue when you rotate or change the layout.
So the easiest way is set the progress view's style.