Navigation controller causing auto-layout issues on screens in Xcode 8 - ios

This has happened on a couple of apps I've been working on, and I believe it has something to do with Navigation bars or Tab bars. I'll work on another screen and be messing with the code and then I'll randomly scroll across the Storyboard and see that all the constraints have suddenly changed values and some items have expanded to 1000 x 1000.
Has anyone experienced this before, and know what is causing it? It's happened quite a few times to me now and it's obviously annoying to reset them each time.

Since you updated your Xcode to 8, you may need to update frames in the whole scene (once).
If you do that each time and it doesn't help, for me changing size of the storyboard helped. For example change from iPhone SE to iPhone 6 and vice-versa.
Now in Xcode 8.1 Beta version, there is a shortcut button for this.
Just select the problematic view's superview (containing mentioned constraints), and click this update frames button:

Related

XCode 8 XIB Autoresizing issue

I have older code, written for iOS 6. I need to implement it for iOS 10 with some new SDK. I have some XIB's. Everything was working perfectly when I was changing them. But in one XIB, when I try to change Image in my Interface Builder of UIImageView, whole layout just collapses. I have 2 views, called TopBar and Content. When I try to change just background image of TobBar View, Content view just collapses, actually, TableView in Content View just goes off the screen on the right and you can scroll to right to see content of a cell. Everything is shifting in my Content View to the right. In my XIB, image view is shifted, TableView is so big to the right. When I place everything as it was, sam thing is happening after build. I have been reading for some time now, and changing from XCode 8 to XCode 7.x in my IB does not work, layoutIfNeeded does not work. Does anyone knows what's the problem? Code still uses Autoresizing masks.
Anyone in same situation as me: in XCode 7 it is working. So, I draw in XCode 7, and build in XCode 8, but I need to build for like 8 times, when it fixes itself. I have reported a bug to Apple.

The issue of Interface Builder in Xcode 8

My storyboards are created in Xcode 7. After I installed Xcode 8, all of them are constantly messed up. When I open one of them, Xcode asks me to select a device (which is a nice new feature). But then it never adjusts views' frames, so I must press "All View: Update Frames" infinite amount of times. And even this doesn't fix all "misplaced" views.
Anybody knows how to fight this problem? Or the only option is to pray that Apple fixes it at some point?
UPDATE 1
It happens every time I open IB, even if I've fixed frames previously.
UPDATE 2
When my colleague fixes same storyboards on his computer, changes stay. No idea what makes my Xcode so special.
I figured out the following workaround
First, set width and height for your view to the values it will calculate on selected device in your storyboard, then preserve superview margins.
This worked for me
Xcode 8.0 has the bug, that it does not save the rects from the storyboard xml-s. So if you fix misplaced views in Xcode 8.0, the problem is gone for as long as the storyboard stays in RAM. When the storyboard is closed and re-read from a file, the issue appears again. (Actually Xcode 7.0 had exactly the same problem in the beginning.)
Xcode 8.1 beta 3 (the most recent version at the time of this writing) fixes this issue:
frames are not 1000x1000, but they stay as they were.

Xcode 8 Storyboard warnings for Navigation Bar width [duplicate]

This question already has answers here:
Warning frame for "Navigation bar" will be different at run time appears in Xcode 8 Swift 3
(14 answers)
Closed 6 years ago.
I am getting constraint warnings for my Navigation Bar's for each of my Navigation Controllers in each of my storyboards in Xcode 8.
To get rid of the warning I set the Navigation Controller's Simulated Metrics->Top Bar setting from Inferred to None and then back again, and the warning goes away. Until the next time the storyboard is opened, then the warnings come back.
My storyboard has the iPhone SE display setting, and the navigation bar's are not Translucent.
Changing the device preview from iPhone SE also removes the warning.
Xcode 8 has some serious bugs in Interface Builder: as well as this one, it has a nasty habit of random-seeming frame changes to all sorts of views - in my Main.storyboard, it decided to make some keyboard input accessory views 1,000 by 1,000 points, and everything inside it had a frame of {0,0} - {1000,1000}.
Did the same thing to various UITableViewCells, but not all of them.
Changing everything back took ages, cleaned the build folder and recompiled, but the problem came back straight away as soon as the storyboard was opened.
I had to uninstall 8 and go back to 7.3.1,
I filed a radar, saw other people with the same problem on the dev forums.
I encountered with the same problem. I am not sure that is solution or not but I just changed the Simulated Metrics size which is page size from freeform to the Page Sheet and warning dissappeard
Regarding the issues of Xcode automatically moving some views/subviews to {0, 0, 1000, 1000} frame bug, which is related to main question:
I had the same problem. Make sure to use Xcode 8.1 now as this problem is fixed in that version.
Xcode 8.1 Release notes
https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
Radars related : 28221021, 28244619
Update - Pointing the explicit frame bug solved on Xcode 8.1

Screen Shift on UIInterfaceOrientationLandscapeRight

I've got this application mainly displaying photographs.
The app was originally written for iOS 3.1 and upgraded to 4 before beeing published. It was not touched ever since. Now that the owner of the API appied some changes which ain't as compatible as they thought, I am forced to update the app. So I'll have to go for iPhone 5 and 6 and 6+ and iOS 7 and 8 updates in one go.
I observe this behaviour in the simulator of iphone 4, 5 and 6+ dimensions.
Portrait looks fine.
Landscape left looks fine too.
Landscape right is screwed up. Apparently it looks as if the whole screen were shifted to the left.
This is strange because I am not aware of anything that I would do different for landscape right or left. All I am doing is differnicating between any portrait and any landscape orientation.
It worked fine in the old version. But frankly I cannot reproduce this any more because I don't have access to the old xcode and sdk versions. But the app is in store for years and works fine on modern devices and modern OS versions.
A bit more background info, just in case it is of importance:
The app is based on a UITabBar, but it is not visible in this view.
The image is scrollable. It is placed on one view three times of the size of the screen with preceeding and succeeding image views place to the left and right respectively. This view with the three images is placed within a scroll view of the size of the screen or window respectively. This concept still works file, it is just shifted.
When I check the view item's frames in debugger or with NSLog, they all seem to be right, starting at (0.0/0.0) or respectively.
The view on the bottom with the four buttons that navigate to related functions and their view controllers, is re-alligned programmatically on each rotation, as well as the overlays with the textual information. All works as it should but it's shifted in this one orientation.
Well, all views are layouted programmatically on each rotation.
There are no constraints defined.
iOS6/7 deltas are all set to 0.
The app "wants fullscreen". By tapping on the image all UI items disappear and re-appear on the next tab. (Just by setting the .hidden attribute. Except for the navigation bar. Thats managed using setNavigationBarHidden:animated: with YES on animated) Works fine, even in the shifted view.
I am running out of ideas.
While I put all the details together for the question, eventually one idea came to my rescue.
The issue is related to hiding the tab bar. I could not use the regular way of hiding the tab bar because then it would not re-appear when navigating down to the functions that are associated with the buttons on the bottom overlay view.
Therefore I did some sort of hack. I did not hide it regularily but moved the tab bar out of the screen.
AND: This was the only thing that I did differently for landscape right and landscape left. I just searched for the constant names and found it.
Apparently, manipulating the tab bar view had a flaw in older iOS versions. (Or in older SDK versions, I am still working on that important detail)
To overcome the flaw the tab bar view was modified this way for landscape right:
[self.tabBarController.view setFrame:CGRectMake(0-kTabBarHeight,0,width+kTabBarHeight,height)];
This does not seem to make sense but did help me out a lot on similar issues years ago when the app was written.
Now, I changed this to:
[self.tabBarController.view setFrame:CGRectMake(0,0,width+kTabBarHeight,height)];
which is the same for landscape left too.
For the time beeing I separate between iOS versions >= 8.0 and smaller. But I'll double check that with older devices and may get back to this answer later.
I leave the question posted because I found the original "hack" here on SO too, so that I guess that others will have the same issues when updating to ios 8 or SDK 8 respectively.
Thanks for listening.

In xcode 6.1, interface builder deleting ui elements

I have a view with some tableviews and some collection views and also some buttons and labels.
I'm not sure if this is new with Xcode 6.1 because I have not worked on the ui aspect of this project for some time. However, when I try to resize just about anything in the view, my tableviews and collection views, and possibly some other elements I am not noticing, get deleted. Specifically, it seems their frame or rect propertied get deleted.
To be clear, this only occurs when I attempt to resize the element by dragging the sides in interface builder. If I resize them by changing the numbers directly either in the IB sidebar or in the xml, this does not happen.
I'm wondering if this is a bug in Xcode or if I have done something to cause this behavior which I can change.
Thanks!
I acheived a fix, at least for this project by turning off auto layout in "show the file inspector" -> "interface builder document"
I have never used this feature in the past so I do not know if it was on in the past but I am wondering if the new Xcode version turns it on by default where the others left it off.
It may also be possible that it has always been on but there is a bug in the feature in the new version.
This fixed the issue for me, at least in this particular project and at least for now. I hope others find this useful.
From here it looks like a bug in Xcode 6.1.
I created a clean project and the behaviour is the same on my machine:
https://github.com/nasht/Xcode6ConstraintTest.git
Resizing one view makes others disappear. Changing a layout constraint from a = to <= or >= also seems to do it.
I've raised a bug with Apple. Suggest you do the same.
workaround: You can install xcode 6.01 and use interface builder from there. You can still compile and run your code using xcode 6.1 if you're relying on xcode 6.1 specific features. (you'll need to rename your xcode.app so you can run both instances. ) It's ugly, but it works.
I found that it's fixed on the next version of xcode (6.1.1)
same problem, yosemit and xocde 6.1. I can resize some view only if i disable autolayout.
I think I ran into this 'problem'. I believe this was because one of the constraints I had was not setup correctly.
What OS X Version are you on? I updated to Yosemite today and 6.1 along with it. When I would resize a label my other elements were not getting deleted but instead getting resized and repositioned. The width / height would change to 0,0 and the x / y would change to 0,0 as well.
I was noticing other issues with Yosemite so went ahead and did a time capsule restore back to Mavericks and Xcode 6.0
I had the same problem in universal app; iphone works fine and the ipad doesnt work.
I'm using xCode 6.1 and OSX Yosemite
My app supports iOS7 and iOS8 and i had the same problem on iOS7 on iPad version only
Fix:
So i fixed it by setting Simulated Metrics in interface builder by
Size = iPad Full Screen and Orientation by Landscape or Portrait
I have got the same kind of problem with Xcode 6.1 and Yosemite :
I have created a view that I have added to the main view, so it appears like a sub view in the View Controller Scene.
Then I resize this subview to 320 x 568. My program works. It corresponds to the program dropit of Stanford CS193P Lecture 9.
I save the project, close it and reopen it : the subview has its width and height set to 0 !
I tried to open the project dropit of Lecture 8 that is quite the same, which was working before (I think in Xcode 6) and same problem ! First I thought that tapping (related to the subview) was not working but found out that tapping was not working because I was tapping on a subview which has its width and height set to 0 !
I have reset the size class wCompact hAny to which all the UIElements are added. and got corrected.

Resources