Xcode 8.0 layout issue after open storyboard and perform update frames - ios

I developed a project using xcode 7 and i updated my xcode to version 8.0 . According to the below steps it happens (I just wanted to show in which step this layout bug appears).
i opened my previous project and run in xcode 8 it works fine at first without opening the story board from xcode. (This is only a one view of my app).
And i open the story board by selecting iphone SE (new feature of xcode 8)
i ran the project after opening the storyboard, then this view looks fine too but the storyboard view was a mess
(but many other views looks messy in my iphone after opening the storyboard)
storyboard view looks like this
according the the stack overflow researches i perform "update frames" action in storyboard to this view. after that it looks good in storyboard
but it looks wired when run in iphone after perform "update frames"
is this a bug in xcode 8 or any solutions to this. this layout issue starts after opening the storyboard from xcode 8, without that it works fine in UI

you can check this link :https://forums.developer.apple.com/thread/63133 it should help you a little bit , or (I have done this option in my projects) you can change the frame( of ViewController) to freeroam (600, 600) , if your view looks totally different. The final option is to make you constrains again to fit the ViewController's size(the longest but I think that the best option).

Did you put your UI in a subview?
Cause I have the exactly same problem with you,
and I solved the problem by adding " self.layoutIfNeeded() " in the area which generate my subview.
Hope this help.

This issue is resolved by Apple in xcode 8.1 please download the new xcode and try it again running on simulator or device you may get this issue resolved i have done this and it resolve my issue at once while i am now using xcode 8.1.

Related

storyboard refresh issue Xcode

I have an issue of storyboard refresh all views, when I change constraints it cannot be change in storyboard but change in simulator and device.
But when I reopen my project then it refresh.I tried below step but nothing happened
Select storyboard->editor-> refresh all views
and also automatically refresh already checked.
Is this bug of Xcode 9.3?
Here I attach image:-
but in simulator look like perfect below image:-
Thanks you.
I have also gone through this strange issue. I believe it creates if your project becomes so much heavy and lot of storyboards used. Therefore using Xib instead of Storyboard is the good option.
If you restart xcode and reopen your project then you can see your view as expected with updated constraint.
I got the answer it's happened due to IBDesignable in my custom library class.If I remove all IBDesignable it's work fine.
Thank you.

Xcode 8 storyboard error

Anyone can help me something goes wrong with me, I cant see my storyboard View, subview, imageview. All became white and its show error like on storyboard file
"An internal error occurred. Editing functionality may be limited."
I have open my project in xcode 8 and 8.1 beta latest xcode but both have same issue.
Main thing is that this is happening with all project not just one.
For example i am opening new project that is open in xcode 8 and i cant see that storeyboad file. Old project is working fine which are not open in xocde 8 i can see that project and open in xcode 7.3.1. but if i open that in xcode 8 and convert to xcode 8 compatible and this issue happen.
I have the same problem with Xcode.
I resolved it by disabling SIP (System Integrity Protection):
Press Command-R when start hold til logo and loading status appear
Open terminal
In terminal print: csrutil disable
Restart system
I have also faced this issue and resolve it by only follow these steps:-
Go to Xcode -> Preferences
Select Locations Tab
Click on Derived Data arrow.
Trash Derived Data Folder.
Restart System
Automatic Fixed this issue.
May this help you.
They inserted autolayout a few versions ago, exactly for this foreseeable reason. It's highly discouraged to use storyboards without autolayout, if you want to work with size classes, different devices with different screen resolutions, orientations, ecc.
My suggestion is revert the project to previous commit, reopen it with xcode7, add the needed constraint and reopen with xcode8 (you will still have problems, because of the many bugs of the new storyboard but they are mostly fixable).
Another option to keep working with in xcode8 it is to use a "freeform" simulated size from the Size inspector of the view controller and adapt the sizes to the old viewcontroller dimensions, but you will have to manage compatibility with all devices sizes programmatically, as i hope it is already being done. It doesn't anyway guarantee that everything works
There are some bugs in storyboard of xcode 8 so if you are not using autolayout then you should use xcode 7. now as you said in question that you are getting problem to open storyboard in older xcode (i.e. 7.x) that because once you open project in xcode 8 then it's change some configuration of storyboard which are not compatible with older xcodes.
So now for solution Open your project in xcode 8 -> open storyboard -> File inspector -> Under Interface builder document -> select xcode 7.x instead of latest xcode 8 from Open in
It will show popup something like Saving for Xcode 7.x will close your document and data for Xcode 8.0 features will be removed. Click Save and close the xcode 8 and open project in your older xcode (7.x) and you will able to open storyboard as it was before!!!
You can refer below screenshot,
Hopefully Apple will fix issue related storyboard and in newer version of xcode 8 you will able to switch project without messing up your UI! But right now there should be a workaround as i mentioned above! Try it!!
for me I just make all the views in storyboard size to inferred
^^"

Layout issues after updating to Xcode 8

Here is a before and after of one of my screens after I upgraded to Xcode 8.All I did was open up my main.storyboard and from there, I built and ran my app on my phone.In my version control, I can see Xcode is doing a lot of changes to my main.storyboard just from me opening it. Whenever I delete those changes, I can see what I use to see in Xcode 7.3.1.But, as soon as I re-open interface builder with my storyboard, I see those changes come back into place. Is there something I can do here?
Before Xcode 8
After update to Xcode 8
I had a similar problem with tableview images not appearing once I converted the storyboard file to be Xcode8 compatible. This looks like a bug with Xcode8, so until a bug fix is released, here is a work around:
Open your storyboard in Xcode 8 and choose an initial device view. Make changes as you normally would.
Once you have completed your changes, select the storyboard -> File Inspector -> Opens in -> Select 'Xcode 7.x'.
Select 'Save and Close' when prompted
Your storyboard changes will be saved, and your storyboard will function as it did pre-Xcode8.
When you need to make other changes to the storyboard file, follow these steps again.
XIB or Storyboard set default as older version 7.x and Save and Close. Temporary solution, but works. Don't open again once you have done Save and Close. Otherwise again need follow same steps from begin.
Eh the same problem. I partially managed to fix it in the following way (for Xcode Version 8.1 (8B62))
In the document outline of Storyboard, I clicked on each scene which had the yellow arrow indicating some layout issues (Number 1 on the screenshot)
After this, for each problematic scene, I had to click on "Update Frames" small icon (Number 2 on the screenshot) which fixed all the layout issues per scene.
However one scene in my case was still in crying state after transition from Xcode7 to Xcode8. I had to fix it manually by adjusting constraints or adding missing constraints.
Phew, not nice surprise of XCode8 and Storyboards. If you used AppCode editor, you won't have such problem, since it doesn't support Storyboards ;P
Good luck!
Xcode 8.1 Beta 2 resolves this issue. Please check this download link
https://developer.apple.com/download/
Please follow the threads for any possible solution:(I believe it happens to many developers).
Xcode 8 GM seed Storyboard issue
Xcode 8 - Previous storyboards getting distorted
(I used anyH anyW width 600) When Xcode updated to Xcode 8 it changed all my ViewControllers size. As a result all the layout was distorted.
Currently I see only 3 solution for the issue (I wouldn't trust on waiting for fix soon).
1.Go for each Viewcontroller and fix it it by Update Frames.
2.Go to the main ViewController Size Inspector -> Freeform -> 600 as most of the controllers are inferred it will change the size for
all of them.(Be careful on the impact of new Features Apple my want
to introduce).
3.Discard the changes in git for the storyboard (I would't suggest it because Apple also inserted some updates which may be important to
Xcode).
Additional link for the new AutoLayout features in Xcode 8 (WWDC16):
Making Apps Adaptive, Part 1
In my case works solutions suggested by Akhil Kateja and I also need to reset Width and Height of the main view:
1) Set View Size to Free Form
2) Reset Width and Height of the view to the original size:
Finally save and you are done.
For me the solution was simply to click on the UIViewController having issues and then Editor > Resolve Auto Layout Issues > All Views In ... > Updates Frames
It re-arranged the views to fit the existing constraints based on the newly selected default view (iPhone 7 in my case).
Also note: if you get a Navigation Bar Misplaced View warning like I did, simply select the UINavigationController/UIViewController and then Attributes Inspector > Bar Visibility > Shows Navigation Bar - toggle it OFF and then ON again.
Setting View Size to Freeform from Inferred worked for me. It can be found under the heading Simulated Metrics in Attributes Inspector.
I had the same problem and I've solved it by force update the controller's view constraints. Put the following code in your viewDidLoad() function
self.view.layoutIfNeeded()
I selected each controller and clicked on "Update Frames" and it fixed the layout.
The answer from #david-truong (https://stackoverflow.com/a/39589860/1407528) is not working in my case, so if you are in my same situation, try this:
Download the previous Xcode 7.3.1 from here: https://developer.apple.com/download/more/
Undo all your changes (if you have a code manager like git. If you don't, you should 'https://githowto.com/')
Open the project with Xcode 7.3.1.
In the case you have all your devices updated to iOS 10+, this version of Xcode will not recognize those devices as compatible devices. So, try with this trick:
Go to: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
Copy the folders related with iOS 10 or 10.1 to: /Applications/Xcode 7.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
Open the project with Xcode 7.3.1 (restart Xcode if you have it already opened)
Select your connected iOS 10+ device
Push Run
Note: New features like Swift will not be available using this trick, but you should be able to load and build your project.
Hope this will help
When i updated Xcode from 7.3 to Xcode 8 and run the app, some of the views are perfectly displayed but some are distorted.Then, i checked the nib file and it prompted me to choose particular device size and then show the nib according to that device size which is offcourse not Any-Any(Xcode 7.3). So all the nibs file are not displaying in a correct way.
Solution work form me :- press the yellow arrow like showing in image below
it will prompt a pop up which show options like
choose Update Frames with Apply to all views in container checked.it will solved around 90% of distorted UI and rest of the auto-layout constraints problem can be solved manually.
I fixed the issue using the Xcode Version 7.3.1 you can download the .dmg file from apple developer portal. I used the Autoresizing in every app and it works great for me.
i will update to Xcode 8 only if they can fix this bug.
Download it here: https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg
To fix a similar problem, I configured the xib as Freeform (not Inferred) AND saved xib file as Xcode 7.x compatible. Both steps were required in my case. I hope that helps!
I notice one new button in Xcode 8.2, (check the orange circle in the image). It will give you some help.
Steps:
1. Open the storyboard and select any device you want
2. Just select the View Controller
3. Click the mentioned button (as in Image)
4. It will updates the frame for that view controller and you can proceed with it
I didn't found any better solution than this. Please reply if found one.
update constraints and layout subviews in viewdidload solves the problem
- (void) viewDidLoad {
[self.view updateConstraints];
[self.view layoutSubviews];
[super viewDidLoad];
}

Weird space in iOS7

I just ran a demo app on iOS 7 target, this is what I get:
I'm using a storyboard and it looks well in iOS8. Constraints are correct.
I already checked e.g.
UITableView is starting with an offset in iOS 7
but the issue in this case is the whole thing, incl. status bar has the offset, no idea what this is. I played around with the layout settings of the view controller in the storyboard without any effect.
I also created a brand new (single view) project, ran it without changing anything, got the same issue. Don't know what can go wrong in a new project concerning autolayout as I can't set any constraints in the root view controller's view...
Any ideas?
Thanks in advance.
Try adding a "Default-568h#2x.png" launch screen to keep your iOS 7 device from running the app in Letterbox mode.
What Apple really wants you to do is use Auto-layout (see point 1 in the linked blog), which is what I suspect your demo app isn't doing.

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