How to set correct view hierarchy in Xcode 7? - xcode

Simple problem but can't find the answer.
In xcode, I have set up a simple UIView with dark background color and on this UIView I have put an UILabel. When I run the app, the label is not shown. Debugging the view hierarchy shows me that for some reason, the UIView is displayed in front of the UILabel.
How can I set the UILabel in front of the UIView? I remember encountering the same problem in XCode 6 and was able to bring the UILabel to front but can't now find any advice on how to do this on XCode 7.
Thanks in advance!

After 3 hours of surfing the net I figured this out (5 min after posting this question...)
In Xcode, select main storyboard -> view controller scene. There under view you see all and indextree with the UIViews and UILabels you have set up. On the list, first items get apparently drawn first and the last items last. All I had to do is move my UIView above the UILabel in the list and problems sorted itself out.

Related

How to #IBOutlet in the storyboard?

Watch question
I am new to iOS development. I got a project to maintain, the problem is that I can't find where in the storyboard belongs the variable. For example, in my ViewControl there is such a line
...
#IBOutlet weak var imgBottomFade: UIImageView!
...
So, I need to find this UI view in the storyboard, I open storyboard, but I see there are more than 10 screens each of them pretty sophisticated, and I start to click on each view on the screen and check the name (equal to imgBottomFade), one view by another, one screen by another... pretty annoying, I believe in XCode should be kind of way to find out where the UI view connects from Controller to Storyboard.
Let me know what I missed?
What you could do:
-open both code file and storyboard
-zoom out to view the whole storyboard (25% or smaller scale factor)
move mouse over the black dot in front of IBOutlet
-observe carefully in storyboard: you should see the UIImageView highlighted
or
-search for imgBottomFade in the search bar (at the very top left)
-you will find at the end of the list a reference to Main
-click it
-that will position the storyboard on the relevant VC
-expand view in the left panel of storyboard
-you should easily find imgBottomFade in the list of objects.
or
-search ViewControl VC in storyboard (just 10 to inspect)
-select it and expand its view object in the left panel of storyboard.
-you should find imgBottomFade in the list of objects.

XCode 6.1.1 UITableView White Spacing Gap

I have been running into some issues where my UITableView after being dragged and dropped into my view controller appears with a sizable white space gap from the top of the element ot the start of the prototype cells. Why does this occur by default and is there a way to remove this? Maybe in the size inspector?
I was having the same issue in 6.3.2 and all I had to do was to go to the ViewController's attribute inspector and uncheck the "Adjust Scroll View Insets" in the layout information section.
Sorry, they won't let me post images, but that solved the frustration for me. Hope it helps someone else.

App display does not fill iPad screen

I'm converting an app that I made for iPhone to be used on iPad. Using constraints on the Xcode 6 storyboard is killing me right now.
With my rep score I can't post an image of what I'm getting, but basically even when I set the constraints and the placement of the object (a UIView) on a storyboard sized for iPad, all the objects on the viewController fill only the top/left area of the screen.
What's the best way to handle this?
-- when you change size of view, other view will be auto change to {0,0,0,0}, isn't ?
but it doesn't change in the right panel.
it is your storeboard files some settings have some wrong.
Demo test link http://www.cocoachina.com/bbs/job.php?action=download&aid=80409
Check for those points:
hope this can help you.

Static UITableView not showing cells with subviews (UIButton, UISlider etc.) in Content View

I've run into a peculiar problem with Xcode. I have a custom UITableViewController that appears as a popover for a few settings in an iPad app. It's a static table view with just 3 cells in 2 sections. It looks fine in the Storyboard editor, but at runtime the cells with custom views (UILabels, UISlider, UIButton) do not show up at all, but those custom views do (in random places).
When I delete the custom elements from the cell or change the cell to anything but custom then they show up fine, even if the view (like basic for example) contains a label in its Content View. It's a lot clearer to see with the attached picture.
To solve this, I've created a completely empty cell below those with custom elements. It looks fine, but I can't interact with any elements. User Interaction is enabled for all elements, cells, and the entire table view. If you have any ideas how to solve that or how to get the cells working properly so I don't need the blank cell hack that'd be much appreciated!
I'm using Xcode 6 beta 7 on OS X Yosemite, programming in Swift.
Thanks in advance!
The question has been answered here Stack Overflow Setting up Auto Layout connections from the label to the Content View solves this issue.
It was a combination of the above link as well as this one that finally solved it.
I added the 4 constraints from each object (UIButton and UISlider) to all four sides of its cell's Content View (top, bottom, leading, trailing). Then, I had to check the "installed" checkbox for each constraint, which was not checked.
Thank you so much for your help, it's working great now!

UITableView Stretching Issue

I have a UIViewController that has an image and label at the top followed by a UITableView. In the IB it looks perfect, but when I run the application in the simulator the UITableView is stretching and taking up the entire screen.
I've turned off all autosizing and set all of the values for stretching to 0, but it's still taking up the entire screen. I even tried some advice I saw on another post which suggested putting the UITableView in a UIView that was sized, but that did not work either.
Any suggestions on how to stop the UITableView from resizing and filling the screen? I am running XCode 4.2.1 with iOS5.
You can give frame size to your tableView like this-
1) make your tableView's IBOutlet property in .h class, and synthesize in .m class.
2) connect it in Xib.
3) than in your .m class place this code in viewDidLoad-
tblView.frame = CGRectMake(0.0f, 30.0f, 320.0f, 50.0f); // you can give any size to your table

Resources