Swift Storyboard List view Not Working? - ios

Been following tutorials online to create a scrollable list view in the storyboard.
I have done the following
View Controller --> Scroll View --> Content View
The scroll view is constrained to the View controller.
The content view width is constrained to the View controller.
The contentSize is set to 1000 height for the content view.
The story board is set to 1000 height.
The scroll view is set to 1000 height.
It appears to only scroll down half way
Any ideas on what i have done wrong here
Thank you

try to remove the height constraint for the scrollview, and fix it to the bottom of your parent view.

Related

Can't scroll with collection view inside scroll view

I have the following structure:
- Scroll view
- UIView
- Collection view
I gave the UIView the following constraints:
top, left, right, and bottom = 0
Equal width and height to the Scroll view
I've also disabled scrolling for the Collection view, as I want the whole page to scroll together.
However, when items are added (dynamically) to the collection view and I try to scroll, nothing happens.
What am I doing wrong? How can I make sure that the page scrolls all together?
Maybe you should try removing the equal heights between view and scroll view because this limits view's height and doesn't allow collection view to grow.

ScrollView is Not Appearing

Reference: Add a ScrollView to existing View
I inserted a scroll view into an existing view and now my page is not appearing and I am not sure how to fix this. My scroll view is under the view so I do not understand why it is not displaying.
With auto-layout, the UIScrollView needs to be able to calculate its content size using the available constraints. This is often best accomplished by adding a UIView in the scroll view to act as the content view, rather than directly embedding UIControl subclasses. The content view can then be constrained to be equal width and/or equal height to the parent view of the scroll view. The variable height/width (depending on the scroll direction) of the content view can be calculated by fully constraining the widgets it contains.

How to use ScrollView with multiple textfields with some help of storyboard?

I am trying to put my all textfield on scrollview. My scrollView is not working on run time.
I am not clear what you want exactly.
To work with scroll view in the interface and in autolayout, you need to add a scroll view in the view. After that you should add one content view(UIView) in the scroll view. Then start adding the text fileds in the content view.
Give constraints for scroll view.
Then give constraints for the content view.
Then for all your text fields.
If you want to scroll the scroll view vertically, give the constraint for width of the scroll view equal to the width of content view. This is required to set the content inset of the scroll view.
Please refer this https://www.natashatherobot.com/ios-autolayout-scrollview/

IOS9: UIScrollView offset in UINavigationController

This is beyond frustrating. I'm having an issue with the UINavigationController (and thus UINavigationBar) pushing my UIScrollView's content down at the top, similar to the issues found here:
iOS 7 -- navigationController is setting the contentInset and ContentOffset of my UIScrollView
IOS7 : UIScrollView offset in UINavigationController
I tried both the recommended solutions of either setting self.automaticallyAdjustsScrollViewInsets = true in my view controller's viewDidLoad() method and deselecting Adjust Scroll View Insets in the Interface Builder. Both solutions remove the margin at the top, but as a few others have noted, I can't scroll anymore.
The UIScrollView and ContentView fill the entire view controller. My content view (inside the UIScrollView) contains labels, segments, and a UITextView at the bottom. Does it have something to do with the content in Content View?
I can attach pictures if needed. Using XCode 7, Swift 2, and iOS 9.
I solved my issue. In auto layout, I wasn't setting my content view's height constraint.
Previously, I had pinned the bottom of the content view to the view controller that contained the UIScrollView.
I removed that pin and explicitly set the height. It works now.
I just ran into the same issue. I had an "About" view with a bunch of labels containing static text. I had a UIScrollView inside of a view controller and it was being pushed down. I had a label pinned to the bottom of the screen that was being drawn off page when it was not necessary to do that.
I had the following view hierarchy:
View Controller
View
Scroll View
Content View (UIView)
Label
Label
Content View was pinned to the bounds of Scroll View, but the width and height had equal constraints to View.
I resolved this by adding another UIView as a child of View. My hierarchy looks like this now:
View Controller
View
Inner View (UIView)
Scroll View
Content View (UIView)
Label
Label
I set the height constraint on Content View to be equal height to Inner View. This resolved the issue for me and everything started displaying correctly. Inner View is pinned to the borders of View.
NOTE: In the hierarchies, the Labels should be children of Content View. In the preview, it's showing that the Markdown lists can't go that deep.
May or may not apply to you, but if you have a Nav controller and you don't need it to be translucent you can do something along the lines self.navigationController.navigationBar.translucent = NO;
This may help with your odd offsets.

How to make ScrollView width = to device screen width?

I am making an app that has a (child) View inside a Scroll View. I understand I have to explicitly set the child View's width since the Scroll View won't provide that information to the child, but how can I make this child View's width auto-adjust based on the width of the device?
For example, in the below I've set the width to 380 which centers the "Quotes" in iPhone 6, but makes them slightly right of center in iPhone 5.
You can use auto layout to set the width of your subView equal to your main View by performing a control drag from your subView to your main View like this:
Then select "Equal Widths" from the popup
Select viewController
Stretch the view you want full screen size to the size of the screen
Click the central icon from the three choices along the bottom of the window
You will an icon pop up
The top 4 values will have a dotted red line joining them
click them all
at the bottom of the pop up you will see 'add 4 constraints'
click this
Done!
You can delete the constraint for width. The view will place it self horizontally becuase of the leading and trailing space to superview. No need for a specific width.
I think your scrollview will be scrolling vertically so in that case you probably need to provide a constraint for the height or your view, and update scrollview contentsize accordingly to this.
Since your child view is located in the view hierarchy of your view controller's view you can assign constraints between your child view and your view controller's view.
Ctrl drag from your child view to your view controller's view. You will see option to set them to have equal widths. Select it. Then adjust the constant if you want the width of your child view to be lower.
You can then add leading and trailing constraints between your child view and your scroll view.
Doing it in this way will also ensure that you set the content width of you scroll view dynamically and correctly.
Let me know if it works for you

Resources