storyboard refresh issue Xcode - ios

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.

Related

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];
}

Autoresizing issue in Xcode 8

=== EDIT ========
This issue is now solved in Xcode 8.1. I have checked.
================
I don't know auto-layout properly. So, I am using autoresizing option in my all apps and it's fine for me. I am able to fulfill my all requirements by this without any issue.
Now in Xcode 8, I have migrated my old swift project to swift 3. Now issue arises.
See in image, I have set Autoresizing, and its working fine without issue in all devices until now and this project is live in AppStore, so that I can't show the UI or storyboard.
Now I have to do some update in project. So I am working in Xcode 8 now. But my autoresizing not working properly, as all the controls are come in center and UI is messed up.
And the issue persists in device also. I have checked in simulator and device as well. But problem is there also. Any suggestion and help will be appreciated. Thanks in advance.
EDIT:
Yesterday there is issue in runtime only, But Today storyboard also changed views like this image
Which means the whole UI design is messed up. This is weird.
Facing same issue. As a my point of view this problem is occurred when we use autoresizing and set only inner autoresizingMask to any view controller. Like,
If we use also boundary autoresizingMask at that time not facing this issue. Like,
I don't know this is actual bug of xcode 8 or remove this functionality in xcode 8.
So, Finally my suggestion is that we need to use auto layout in xcode 8.
Please try to uncheck autoresizing from xib or storyboard. And inviewDidLoad set [_scrollView setAutoresizesSubviews:YES];
Try it if this solve your problem
Edit: In case of storyboard uncheck Resize view from NIB option.
I'm not sure about storyboards but I've found a temporary solution for xib files. In Utilities panel (right hand panel) select File Inspector tab. Under Interface Builder Document section, select the file to open in "XCode 7.x". It will ask you to confirm that you do not want to use XCode 8 features, save the file and close it.
Xcode 8 beta 2 solved this problem!! I already checkeded now!
I had a similar issue for scrollView in Xcode8
I have an one solution to work with scrollView
First take a simple UIView and add all component which you want add to in scrollView and give that component to autoSizing
And also take one scrollView and programmatically set view frame and also set scrollView contentSize and add your view into scrollView
like wise, in my case I added this code in viewDidLoad for swift project
// add view to scrollview
self.scrollObjForNextAppointment.contentSize = CGSize(width:self.scrollObjForNextAppointment.frame.size.width,height:410)
self.viewForScrollContent.frame = CGRect(x:0,y:0,width:self.scrollObjForNextAppointment.frame.size.width,height:410)
self.scrollObjForNextAppointment.addSubview(self.viewForScrollContent)
it's work for me, Thanks!
Solved by unchecking "Auto Resize Subviews" to ScrollView
Update the issue seems to have been fixed in Xcode 8.1
Having the same issue and I've found that the offender here is the UIScrollView element. Just move everything outside of your scroller and you will see that everything works just fine, like before.
Which means one possible workaround would be to place your scrollable content in an ordinary UIView, then replacing it with UIScrollView at run time, programmatically.
A moderator kindly deleted my answer here as a duplicate, so see my answer at:
Autoresizing under iOS 10 doesn't work
In response to max, yes, resizing a bunch of subviews can be a pain. That's why I suggested adding a single "content view" to the scroll view and moving all of your existing subviews inside of that view. Autosize the subviews inside of the content view just as you did with the scrollview, and autosize the content view to the scrollview.
It's that content view that you're then resizing inside viewDidLayoutSubviews.
And again, the "content view" inside of the scrollview construct is pretty much the standard way to get auto-sizing scroll views using autolayout, so it should be considered a best practice.
That method is described here...
https://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/
My method seems a little convoluted, but I was able to patch up a storyboard with about a dozen scenes and Vc's in about 15 minutes. It would have taken much, much, much longer to rebuild everything using auto layout.
Apple just came out with XCode 8.2, which fixes this problem for me. I have been using XCode 7.3.1 for my interface design parallel to 8.1, but I can now use 8.2 without any problems.
The storyboard gets updated with widths and height of frames though, to accommodate the new 'View as:' functionality. Though it doesn't seem to affect running on device/simulator.
Curiously, the bugfix it is not noted in the XCode 8.2 release notes.
Original answer here

Xcode 6.3 Crashes when navigating from storyboard to other Swift 1.2 file

I installed Xcode 6.3 which includes support for Swift 1.2. It turned up a ton of error messages, which are mostly casting issues.
I navigated to the storyboard, and cannot go back to any other .swift without the whole thing crashing. I have force quit, restarted, and even re-installed, and I still can't navigate away from the Main.storyboard file.
I have tried the suggestion described here to open storyboard as code, make some changes, revert those changes, save and try again, and still no luck.
Is something in my code breaking Xcode? Is anyone else experiencing this? I had used Xcode 6.3 beta successfully with the same codebase.
Update:
This has now been fixed in Xcode 6.3.1 released on the 21st of April 2015.
I gather from the apple developer forums that this is an #IBDesignable issue. Especially in projects that use custom fonts, additional xibs, etc.
I have somehow fixed my issue by removing all #IBDesignable from swift UIView class definitions. You can open your project directory with TextMate or other, search and remove all "#IBDesignable"
However I still think this is a MAJOR bug, that needs to be worked on.. so keep filing bug reports to Apple.
A temporary solution:
By opening a "New Window" (same project).
One for the code, one for the storyboard or reduce first, work freely with second window.
You can keep your #IBDesignables
EDIT : Bug fixed -> Update Xcode 6.3.1
Launching Xcode while holding shift fixed it for me.
(This suppresses Xcode's state restoration.)
Update: Xcode 6.3.1, released today, resolves this issue.
Update
Xcode 6.3.1
For me, everything works !
Temporary solution:
If you have currently opened Assistant Editor switch to another file using alt+click. You can keep your #IBDesignables.
Here's how I get around this strange bug:
Before launching Xcode, rename the storyboard file in finder so that Xcode won't find it (e.g. add the extension .temp)
Launch Xcode - works fine even if it hanged before since it cannot display the storyboard editor
Open a new window in Xcode
Rename the storyboard file to its original name
In the new window in Xcode - select the storyboard - Xcode does not hang
Minimize the new window and work as usual in the original window. Now you can select any file - even the storyboard - without Xcode hanging
One problem remains, though, at least for me. Every time I select a file or edit something, Xcode needs to recompile the storyboard. Haven't solved that one yet.
I can confirm this bug. I was stuck in storyboard and could do nothing to get out of it (couldn't even open the assistant). As a workaround, with the storyboard open, right-click the .storyboard file and select Open As - Source Code. This will switch your storyboard to code and you will be able to then switch to any file.
It is not a bug anymore since Apple fixed it in Xcode 6.3.1.

Can't see UITextFields UIButton etc Xcode 6.1.1

I created a project (i believe before i update to Xcode 6). Now when i look at storyboard none of my Obects/Outlets (UITextfields/UILabels/UIButtons) are visible, they are still there and appear when i run in simulator.
Has anyone come across this and have any ideas?
Thanks in advance
may be you need to need to re-size the view controller because its default have a universal view so you have to set the size to view-controller for only Iphone.
hope it will work

Xcode crashes when dragging UIElement to model

When I attempt to drag a UIButton to my ViewController.m (control + drag), Xcode crashes. I have tried unchecking the "Use Autolayout" box, but I am still having the same issue. I am using OS X 10.9.4 and Xcode 5.1.1. Any ideas?
That sounds awful and it should not be happening. However, there is an easy solution: do not do that. Control-dragging from the Interface Builder canvas to your code is completely unnecessary; you can do everything you need to entirely by working in the code and in IB separately.
I realize that for you this is not a solution ("why am I crashing?") but rather a workaround, but it's a perfectly good workaround and will allow you to move on with your work.
I just had a similar problem Ctrl-Dragging from a map view inside a prototype cell to the view controller that the prototype cell subclassed from. I mistakenly had an old outlet reference left on the map view, and after removing and saving the change, Xcode no longer repeated the crash.
Do you have more than one version of XCode on your machine? I had the same issue and think there was a conflict because I had XCode 5 and 6 installed. I deleted 5 with appCleaner and got rid of all the extra files. Everything was working after that.
If you only have XCode 5, I would try a clean install.

Resources