Xcode: Button defaulting to centre of view controller - ios

Strange thing happened just now. I set my VC size to 4.7 inch in the storyboard settings and then tried to add a standard button control to the top left of my view controller. It wouldn't let me place it where I wanted, and defaulted to centre position in view controller. Same happened when I tested another UI control. Any idea why this is happening?
Edit: I also can't select any controls from VC in storyboard to move their position. So the button is in centre position but I can't select it from there to reposition.

Related

How to show navigation bar in Interface Builder preview storyboard (assistant editor)

I am doing autolayout works in Storyboard and previewing the result in Assistant Editor > Preview
How can I show navigation bar in the preview?
Take a dummy view and give its height equals to the navigation bar height. (navigation bar height remain same in each device). when u done ur pixel perfection than uncheck installed from attribute inspector of that view or just remove the view.
I suggest another way - just use top constraint, while you container view will have y = 0, you can set top constraint to 44px, in this case you will see warning, but all stuff at your screen will be at the same positions, but preview will display your screen like you have navigation bar. When everything is ok, just set top constraint to 0. I guess this solution is really convenient.

Navigation bar not occupying entire screen

Im trying to create a UINavigationBar using storyboard but the UINavigationBar is not occupying the entire screen.
Following is the screen shot of my storyboard.
In storyboard, it appears to occupy full screen width but in my device, the width is not full. How can I sort this out?
select your viewController and go to XCode Menu - > Editor -> select Navigation Controller ,
for example
you get the output of
it works fine for any layout patterns
firstly you have to disable size classes and auto layout in the file inspecter for your view after then set your navigation bar property like as shown in screenshot. It will be applicable for all the devices.
1- Select your element.
2- Click triangle button at bottom right.
3- Click Add Missing Constraints
use autoresizing selecting your NavigationBar:-

iOS7 - unable to embed a screen in a scrollview

I have a screen that doesn't fit into a 3.5 inch phone screen. In iOS 6 I had the contents of the screen in a scroll view, but in iOS 7 that option is constantly grayed out.
Here is the screen shot
Would anyone know how to add the scrolling to my screen in ios 7?
Thank you!
Second screen shot with the scroll view.
Rather than selecting the entire view controller, you need to have a view selected. The options in Editor -> Embed In are contextual and since you have then entire view controller selected, your only options are to embed the whole VC within a Navigation Controller or a Tab Bar Controller.
If you can't get the right selection by clicking within Interface Builder, try expanding the outline view and selecting your view. Then try to embed your view within a scrollview.
Note that your root view must be a UIView, so you won't be able to embed the root view in a scrollview because that would put a scroll view at the root.
Three problems I ran into that I hope can help:
1) Make sure "Safe Area", or other object that shouldn't be there, isn't one of the objects selected in your view while trying to embed. For a simple test select just one simple object like a textfield or label and see if the Editor -> Embed In is still greyed out and work backwards if you have to.
2) You're going from View > Content to View > ScrollView > View > Content. So after embedding in a scrollview, embed in a view.
3) Once embedded make sure your scrollview is less than your content size, or it won't scroll: https://stackoverflow.com/a/28146729/1323357

Why is the position of my picker in the app different than in the storyboard

In the picture below you can see that I have placed a picker view in the storyboard above the label. However when I launch the app in the simulator you can see that the picker is more or less right on top of the label.
What am I doing wrong here? How do I get the picker to the position where I placed it in the storyboard?
Press ctrl and drag with mouse from label to picker view.
Select Vertical spacing
And that's it.

control-drag from view controller in ipad storyboard to toolbar not auto-scrolling storyboard

I just saw a video demo of control-dragging from the view controller icon for an ipad storyboard at the bottom of a view controller to the toolbar within that view controller. While the view controller icon and the toolbar are not on the screen at the same time, the dragging actually scrolls the storyboard enabling the connection between the two.
However, in my ipad storyboard I am unable to make that auto-scrolling happen and thus unable to complete the control-drag.
Is there a way to make the storyboard scrolling happen while control dragging? I thought of temporarily moving the toolbar to the bottom of the screen to make the connection and then moving it back. But the storyboard won't auto-scroll to let me do that either. I'm using a 13" macbook pro. There appears to be no zoom setting that will have both on the screen at the same time.
Alternately, can someone tell me if there is an alternate way to accomplish that? Which part of the code would I control-drag to?
Thanks.
according to this, one can accomplish the same by control-dragging to the icon of the corresponding element (in my case the toolbar) in "document outline pane" which sits between the project navigator and the (storyboard) canvas.
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/SecondiOSAppTutorial/GettingStarted/GettingStarted.html
doing so would bypass the inability to autoscroll within the storyboard.

Resources