Text views and image view disappearing from view controller in Xcode 6.1 storyboard - uiimageview

I updated to Xcode 6.1 to fix an error I was having with the Interface Builder Cocoa Touch Tool spiking to 99% CPU usage when I used the storyboard, which would freeze Xcode. Now that that error is fixed, I have a possibly even more frustrating error.
When I use the storyboard, while I'm working on a UIViewController, my UITextView, my custom UITextViews (which are subclasses of UITextView, but for all intents and purposes in the storyboard, they're UITextViews), and my UIImageView suddenly disappear!
Here's how the default main view inside my view controller looks right now:
Main View
View
Activity indicator
Scroll view
Label
Text view (x=0, y=-65, width=0, height=0) ERROR!
Label
Custom text view (x=0, y=-65, width=0, height=0) ERROR!
Label
Custom text view (x=0, y=-65, width=0, height=0) ERROR!
Label
Custom text view (x=0, y=-65, width=0, height=0) ERROR!
Label
Label
Custom text view
View
View
Label
Button
Image view (x=0, y=0, width=0, height=0) ERROR!
ViewX
Label
Custom text view (x=0, y=-526, width=0, height=0) ERROR!
Width and height Constraints for this view.
Button
Width and height constraints for the scroll view
Center x and y constraints for ViewX within the scroll view.
Center x and y constraints for the scroll view within the main view.
It all started when I adjusted the size of the view controller using "freeform" in order to see views that were off the view controller screen. Once I used cmd-Z to change the view controller back to "fixed" (to the normal size), the missing elements appeared again and everything seemed fine. However, later on, I was editing the view controller and suddenly...bam! They're gone. And when I reset all of them to where they were supposed to be, it just happened again (resulting in the above described x, y, width, height values).
:-(
Does anyone know what could be wrong? I never had this error in Xcode 5.
EDIT:
I was able to use cmd-Z to get the view controller back to normal. Then I restarted my mac and reopened Xcode. Now, I've noticed that the error occurs whenever I resize anything in the storyboard by dragging with the cursor (it doesn't happen if I resize something using the width and height properties on the right panel in Xcode). It happens on other view controllers as well. Even in a view controller that has only a UILabel and a UIImageView in the default main view, when I click and drag the edge of the label to resize it, the image view disappears with values of x=0, y=-64, height=0, width=0.
CONCISE SUMMARY:
In the Xcode 6.1 storyboard, every time I resize any elements in a UIViewController, all UITextViews and UIImageViews collapse and get shoved -64 pixels above the upper left corner of the view controller.
UPDATE
It appears that Xcode 6.1.1 has fixed the bug.

Another workaround is to add constraints to the layout Before resizing of any views. (add missing constraints e.g.). The bug only seems to occur when there are no constraints available. I have reported the bug to Apple with Bugreporter.
Edit: So, at least it seems that Apple Bugreporter is working. The problem is fixed in XCode v 6.1.1.

Seems it's a bug in Xcode 6.1 !!
The current solution is you should resize your elements from the Size Inspector.
Never do the resizing by mouse...

If you uncheck "Use Autolayout" then it won't occur either. Though, you're back to using the old "springs and struts" method. Still, this can be set on a view controller by view controller basis so it's not too bad.

I was having the same problem. I just went to the Apple Developer website and downloaded the beta version of the new Xcode and they fixed this bug!

I just installed XCode 6.2 Beta and the issue seems to be fixed there.

There are 2 types of 1 is main storyboard and 2 is launchscreen storyboard
Your are placing all your views on launchscreen this appears when you app first time then it will not appear
Place all your views on main storyboard instead of launchscreen

Related

How to fix scrollable content size ambiguity in xcode 11 using auto layout beta 7 UIKIT

When using Auto Layout, I am unable to set up a simple UIScrollView in my view controller in Xcode 11 beta 7. I know that I must constrain the scroll view to the edges, and then set the scroll view width and height equal to the width and height of the entire view that contains the scroll view. However, I am not getting the option to set equal widths and heights when I attempt to do so.
When I do the right-click-drag from the scroll view to the entire main view, I get the following options:
Leading Space to Safe Area
Top Space to Safe Area
Trailing Space to Safe Area
Bottom Space to Safe Area
Center Horizontally in Safe Area
Center Vertically in Safe Area
In other videos, there is an "Equal Widths" and "Equal Heights" option that I don't seem to have.
Am I doing something wrong, or did Apple change the way scroll views work in Xcode 11?
I'm using beta 7 currently
I was finally able to successfully add a UIScrollView using storyboards in Xcode Version 11.0 (11A420a) after much trial and error.
You can add the scroll view directly to the root UIView of the VC or, if you needed to, add it to another UIView under the root view as needed by your UI Design. Constrain the UIScrollView parents normally for whatever your needs are.
Here is the key : when you add the UIScrollView to the storyboard, click on the Size Inspector with the UIScrollView selected. You have to UNCHECK the box that says "Content Layout Guides".
If you do this you can set the scroll view's contraints normally (I did 0-0-0-0 to superview). Then I added a UIView to the scrollview and set it's constraints to 0-0-0-0 and a height of 900 (which is what I wanted).
This will give you constraint errors in red when you set them. They will be fixed by setting the width of the UIView equal to the width of the UIScrollView.
Set the UIView width equal to the width of the UIScrollView view by Ctrl-right clicking on the UIView, dragging to the UIScrollView, and selecting the "Equal Widths" option. This should get rid of your constraint errors.
You actually can then go back to the UISCrollView Size Inspector and check the "Content Layout Guides" checkbox, no constraint errors will appear.
Disable the content layout guides in scrollview properties.
Hope it helps.. :)

OS X App - Cannot Resize App Window

I have an OS X app originally built using Xcode 4, now using Xcode 7. When "springs-and-struts" was superseded by constraints, I reworked the UI to use constraints. Simple enough, and seemed to work well.
Fast forward two years after first release, and for the second release I needed to add controls and increase the height of the main app view. Unfortunately, my test team is using smaller screens and cannot see the whole view. They need to resize vertically.
Problem - even though the resize controls box is checked, the window cannot be resized. The controls do not show at run time. I tried
Setting lower minimum window content size height, but that did not change anything.
Changing content compression resistance did not change anything.
I am thinking this issue has something to do with constraints.... Any ideas on how to get resize to work?
Edit: After playing with a new test app some, I am more certain the problem is due to constraints. I have a control where I have constrained leading and trailing space to superview and width - there went horizontal resize.
I really need to have a view where the user can resize the window, but scroll the content. However, in this case, the content is other controls. I think on iOS, I would use a UIScrollView. On OS X, I have tried a scroll view control and have tried embedding in a scroll view, and neither have the desired effect.
I had the same issue and solved it by adding a view to be used as a "container" in the view controller.
Pin the top left corner of the "container view" to the view controller (leading space 0 and top space 0). Add equal width and height constraints on the "container view" to the view controller. Then move all your objects into the "container view" and add your object constraints on the "container view" not the view controller.
In my case, it happened in this way (Xcode 13.1).
I mistakenly added a view from IB outside of the window view hierarchy. The new view was added as a separated object (a top node in the interface builder file). I added the new view into the window by drag-n-drop.
I found the new view had different behaviours, for example, I couldn't set the top space constraint. With this view in the view hierarchy, I couldn't change the window size (content view size) at all.
I removed the view and added another in the view hierarchy, it worked as normal.
I think IB initialises the view differently if it is a separated object (top node of the interface builder file).

Shouldn't an NSTableview autoresize when its superview resizes?

I have an NSTableview on the contentview of an NSWindow. When I resize the window, I would like the height of the NSTableview to resize. This isn't working.
To make sure I haven't set something incorrectly, I created a new mac project, view-based, storyboard. In IB, I added an NSTableView to the view. It looks like the default is to have autoresizing on, so I made no changes. Run this sample project, resize the window and the tableview does not resize. I guess I am missing something. What is it??
BTW, I am using xCode 6.3
• While viewing the xib, select the Bordered Scroll View that contains your table.
• In the lower-right of the xib canvas, you'll see 4 icons. The 2nd icon is called "Pin" if you hover your mouse over it. Click that.
• In the view that pops up, click the 4 red constraint connectors, then click "Add 4 Constraints".

Rotating iPhone 6 Plus results in gray detail view controller?

I am experiencing an odd issue with split view controllers, and I've been able to recreate the issue very easily in a brand new app. If you rotate the iPhone 6 Plus to landscape the master and detail view controller become visible on screen, but if you then rotate back to portrait and switch tabs then rotate to landscape, the detail view controller will be completely gray as if nothing is there. This is logged to console: <Error>: CGImageCreate: invalid image size: 0x0 I would like to know if you know the cause or what can be done to fix this bug.
The setup is a UITabBarController with three tabs, each tab is the default UISplitViewController dragged out via Interface Builder. Subclass UISplitViewController and change the 3 split views to that class. Set the split view controller's delegate to self in viewDidLoad. Then return YES from splitViewController:collapseSecondaryViewController:ontoPrimaryViewController:. This sets it up so that the master remains visible after rotating back to portrait instead of the default details view controller.
To reproduce the bug: Launch app in portrait on iPhone 6 Plus, rotate to landscape, rotate back to portrait, tap the second or third tab, rotate to landscape
Bug: The detail view controller is completely gray
Expected: The detail view controller should appear like it normally does if you launch the app, tap a different tab, then rotate to landscape
Additional info: Once this occurs, if you rotate back to portrait and then go back to a different tab it will also show a gray detail controller upon rotation to landscape. The app must be force quit and relaunched to see those split views in landscape.
Now I noticed if you open the app and the first tab is displayed, if you rotate the iPhone 6 Plus to landscape, it actually initializes every single master and detail view controller in the tab bar controller (5 additional view controllers) - it stops at breakpoints set in viewDidLoad if you subclass those controllers. I expected it to only initialize the detail view controller for the split view controller that's displayed on screen. I'm wondering if this is expected behavior? I believe it could be linked to this bug.
My question is, is this gray screen a bug in iOS, or is there a problem with this setup, or is there something that can be done to prevent this from occurring?
How it should appear:
How it appears when following the above steps:
I encountered some thing strange myself, while working on my Multiple Detail Views sample. I was actually getting 2 Table Views displayed instead of 1 Table View and 1 Detail view in 6+ simulator. I could fix it by returning my detail view controller from separateSecondaryViewControllerFromPrimaryViewController method of SplitViewController delegate.
My code is like this:
func splitViewController(splitViewController: UISplitViewController, separateSecondaryViewControllerFromPrimaryViewController primaryViewController: UIViewController!) -> UIViewController? {
if let primaryAsNavController = primaryViewController as? UINavigationController {
if let topAsTableViewController = primaryAsNavController.topViewController as? TableViewController2 {
//Return Navigation controller containing DetailView1 to be used as secondary view for Split View
return (UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("detail1Nav") as UIViewController)
}
}
return nil
}
For me it was happening only when TableView2 was TopViewController, so I am checking for it and if true I am initialising my intended DetailViewController and returning it.
Hope this approach works for you as well.

Xcode 5, ios screen issue

when I open my iOS project in Xcode 5, I see spaces bottom and top of the view controls (in 3.5 and 4 inch screens).
There are no problem in Xcode 4. Image view is not covering all view controls area.
I am setting image view size with manually but I have 200+ view control.
How can i quickly fix ?
Have you tried to hide status bar ?
It can cause the issue you are having
If the spaces are only appearing in Interface Builder, you can tell IB what you want to see during layout. Click below a scene on the bar where the controller, first responder, files owner etc. are located. Now your whole scene is selected. Then show the attribute insepctor (Cmd+Alt+4) and select what you want to see in your scene.
Attention - this has nothing to do with your code! Its just how the scene is presented in the editor (simulated metrics)!
If this was your problem, please mark question solved.
If not, please add some more details.
Thanks.

Resources