Scrolling storyboard elements that are off screen? - ios

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.

Related

iOS Container View loads UIViewController with content goes out bounds

I'm loading a UIViewController from storyboard in a Container View but the content appears to start vertically somewhere out fo bounds. Here a simple controller with a view showing a label as example:
What is causing this? How to prevent it?
Found out what was causing it while creating a new project to extract the problem. The view holding the label is inside a scroll view and had its height set to equal the hight of the root view. The root view is however as big as the device's shape and this was what made the content to go out of bounds.

Last view added to content view of scrollview goes behind the home indicator

I have a UIViewController containing a scrollView.
The scrollView is pinned (0,0,0,0) to the Safe Area, this way:
In the body of the viewController viewDidLayoutSubviews, I add some views to the Content View of this scrollView.
I see no issue in iPhone 6 simulator, but in iPhone X simulator something strange happens: the last view I add to the scrollview goes partially behind the home indicator:
I erroneously thought this was the kind of issue solved by the Safe Area.
What could I do to solve this issue?
As of iOS 11 and new iPhone X devices and forward this is the default behavior of safeAreaLayoutGuide.
Scroll view subclasses like table view and collection view handles this problem automatically if you pin the bottom anchor to safe area.
Since you are populating a scroll view manually you need to get the bottom safe area height and inset the scroll view with that value.
You can do it like this:
scrollView.contentInset.bottom = view.safeAreaInsets.bottom
Change the ScrollView BottomConstraint related to superviewBottom instead of safeArea.

Cannot change custom UICollectionViewCell in Storyboard

I have a UICollectionView with custom UICollectionViewCells. I used Interface Builder (via XCode 8) to size the collection view and cells when first making it.
Now, I'm trying to adjust the size of the cells and I'm unable to do so in Interface Builder (using XCode 9). I cannot adjust the width or height of the cells on either the collection view itself or on the custom cell. The up/down arrows don't do anything and neither does typing in a value. It just stays set at 145.
I saw some answers about not being able to do this with a UICollectionViewController via Interface Builder, only a UICollectionView, but it is a collection view and not UICollectionViewController.
I'm sure there's some new setting/config in XCode 9 that I'm missing, but I can't figure out why I can't adjust the custom value.
I ran into the same problem.
Turned out that the item size was defined by the contained flow layout. So editing the item size in the flow layout, and the parent collection view had its item size changed accordingly.
I tried Jonny's answer, but I use a custom FlowLayout and couldn't edit it's cell size either. I had to manually edit the size of the collection view, the cell and the layout in the storyboard source code (right-click on the storyboard in project view and select "open as / source code").
Now the size is correct but still not editable from the UI ¯_(ツ)_/¯
Same problem, width would not change. But I changed the height to something different and it then let me edit the width.
Xcode 12.3. I had the same issue and what fixed it for me was changing the collection view scroll direction from vertical to horizontal to make the change, then obviously reverting back to vertical (my intended direction) once I was done editing the values.

Vertical View Pager either in Swift or in Objective C

Is it possible to implement Vertical ViewPager or not?
if Yes the please suggest me how to do it.
I am working on an app, which is similar to Quiz App.
I want to implement Quiz App result screen in which I am looking to implement Vertical View pager.
Thank you
Abhishek
So that's simply a scroll view, or a subclass of (I.e. A table or collection view). The scroll direction is controlled by the content size (or the layout for the collection). Any scroll view can have paging enabled.
If using a table or collection you simply need to set the row height or item size to the size of the view. For a plain scroll view you add the page views as sub views and set their size to equal the scroll view frame.

ScrollView inside View or Vice Versa?

I am working in iOS and cannot find if there is a definitive answer to this.
I have a screen, the entire thing will scroll (not just part of it is scrolling at the top). I am using Storyboards to build this and the content is bigger than the screen size. Is the best way to do this with:
This is all inside of a UIViewController.
The content inside a View (child) inside a fullscreen ScrollView (parent) and set content size of ScrollView as the View's frame.
The content inside a ScrollView (child) inside a fullscreen View (parent) and set content size of ScrollView as its frame and then its new frame as the View's frame.
Just a ScrollView as the first child of the ViewController and set its content size as its frame and then its frame as the screen size (which I would need to check at runtime?)
All of these methods seem to work, but they make other things easier/harder (moving content for keyboard, etc.). Is it simply a matter of opinion or is there a "best/correct" method?
You have to set content size bigger than your view. Then It will scroll.

Resources