Storyboard placement incorrect - ios

I have a UIScrollView placed inside a UIScrollView container. While the placement of the sub-view appears correct in the Storyboard, it is off when I run the app (both on the simulator and an external device). In order for the view to appear properly, I have to place it oddly in the storyboard as follows:
Layout appears correct in storyboard but incorrect in app:
Layout appears incorrect in storyboard but correct in app:
To enable vertical scrolling in the parent UIScrollView, I turned off Auto Layout, and for the ViewController, I set size to 'freeform"
Does anyone have advice for how to layout my views to appear correct both in the storyboard and in the app?

Related

How to give constraints to a tableview when tableview cell is on xib. And table view is on storyboard

I have a table view on storyboard i.e. FirstStory.Storyboard. And for this tableview I have created a table view cell on xib file where I give size to its width as per my current storyboard width. But when I launch my app it runs fine on the landscape position. But when I rotate it in the portrait mode. Width is unable to show the all item which I placed in tableviewcell.xib. How we mutually combine these two item in storyboard (table view on storyboard while cell on xib). Which follow a single constraints with above condition.
UITableViewCell's contentView property is always the size of the cell. So you have to setup the constraints of your UI components in the xib file with the Cell's contentView properly. The issue you are facing must be because you did not setup these constraints properly.
To see which views or constraints have been placed wrong, use the XCode's 'Debug View Hierarcy' feature.
Launch it from here
Run your app, navigate to your tableView, then press the above button to launch the view debugger. It provides very good insight into your constraints and where the issue may lie

Width and height not adjusting with Xcode Auto Layout

I have created an interface for my app in Storyboard under the Any x Any layout setup, when I run my app the layout is still sized for the square Any x Any and not the phone screen. I want the app to adjust to all sizes and not use a set layout for set screen sizes. How can I do this?
Here are pictures to show my design, and the outcome of running the app.
Storyboard View
Simulator View
The table view is also cut off here
If your ViewController is subclass of UIViewController then add leading, trailing ,top and bottom constraints to UITableView, and contains to your custom navigation bar. or If its subclass of UITableViewController. No need to add any constraints. Just embed your TableViewController into NavigationController.
Hope this will help you
what exactly are you trying to achieve? Your tableview to be entirely on the screen, so not scrollable?
If so, then you should override the layout of your tableview and its corresponding cells. As those cells (and the number of them) define the height of your tableview.
From what I can see it appears that you have manually added a UINavigationBar. I personally find it much easier to embed your view controller into a navigation controller. This will provide you with a navigation bar that will automatically resize depending on the hardware, or size class, of the device. To embed it go to: Editor -> Embed in -> Navigation Controller.
Your TableView seems to be fully in the screen as well? If you have layout issues with your cells not adjusting then I will be more than happy to help you once you clarify what is not quite right.
Hope this helps.
Yep. Been there, done that. Just because something is centered in the Any x Any view in interface builder does not mean it will also be centered e.g. in an iPhone simulator. You always need to make your layout choices explicit with constraints, i.e. in the this case add a "center horizontally in superview" constraint or align the right and left edge with the superview (I really would need to know more about your view controller in interface builder to tell you exactly).
Are you familiar with constraints or should I add some more detail on how to solve this?

UIView at bottom UIScrollView does not appear

I'm trying to get an UIScrollView working with my Storyboard. It works but the UIView at the bottom that I use with a gesture tap for getting back is not showing. How can this be?
So everything works expect that. This are the things that I did:
Set freeform in Storyboard
Disable auto layout for the Storyboard nib
Changed the freeform dimensions to X:320 Y:800
Dragged some labels and stuff in the Scrollview
Created an outlet for the ScrollView
Enabled scroll programmatically
Enabled Contentsize CGMakeSize() programmatically;
So I normally did everything, why isn't my UIView showing up at Y:750. The only thing I do with the UIView is setting the Background/CornerRadius.
It would be if your UIView is no included in the calculation for the content size. Other than that I cannot see anything obvious.

Scrolling storyboard elements that are off screen?

I am using Xcode 5 and ios 7. I have a view which has size 320x1200 which contains various static elements such as buttons,images etc.
I created View controller,
I added Scroll View of same size to this View Controller
I Added View to Scroll View and changed the size of the view to 320x1200
I selected main/root View Controller and used EDITOR -> Resolve Auto Layout..-> Add Missing Constraints (to enable scroll).
Now I can scroll but I still cannot see the off screen content. Is there any way to resolve this.
Resize the Scroll View to the root view's size (e.g. 320x480 on iPhone 4) and set its content size to 320x1200 instead.

Unresponsive UIScrollView after dismiss modal view

This issue is driving me crazy.
I have a UIScrollView with a content view that doubles its size. Scroll is enabled and contentSize is set. The content view has a pair of UICollectionView side by side so you can scroll the view between both of them (scroll paging is enabled too). Everything works ok until I select a cell. The app presents a modal with some info and, when I dismiss the modalview, the scrollView becomes unresponsive and doesn't scroll (but I still can select the collectionView cells!). It even change the contentOffset with animation to the proper "page" but doesn't scroll at all when dragging.
It sounds like the good old contenSize error but when I log the sizes in viewDidAppear, it has the right size.
FYI: I'm targeting iOS7 and I set the scrollview layout using storyboard with AutoLayout.
Any help will be appreciated
Solved. It seems that the constraints I set in storyboard weren't recreated when the modal was dismissed (I don't know why). Creating the layout by code did the trick.

Resources