Paging UIScrollView in increments smaller than frame size
Try making your scrollview less than the size of the screen (width-wise), but uncheck the "Clip Subviews" checkbox in IB. Then, overlay a transparent, userInteractionEnabled = NO view on top of it (at full width), which overrides hitTest:withEvent: to return your scroll view. That should give you what you're looking for. See this answer for more details.
UIScrollView bounces when content is smaller than view's size
see UIScrollView (paging mode) bounces only when there two or more pages?
you'd better set the property:
scroll.alwaysBounceVertical = YES;
scroll.alwaysBounceHorizontal = YES;
Incorrect Page size in UIScrollview Paging
In ViewDidLoad maybe the frame of your scroll view was still not set.
Try that code in ViewDidAppear and check if it works.
Advice: You should subclass that UISCrollView and initialize the view there, not in the ViewController.
Let me know it that worked!
Regards.
UIScrollView paging from center to left and right
You should make 3 pages, so the contentSize should be 3 times the size of one page, as far as i can see, that is happening.
Now make sure the user always starts on page 2 (the center page), do this by setting the contentOffset to 1x the width of the scrollView for the x coordinate and 0 for the y coordinate.
After that, the user should be able to scroll left and right.
PS: by looking at your code, it seems like you are assuming everybody uses an iPhone 6 (width of 375pt), you might want to use the calculated width (by using self.view.frame.size.width
or something relative)
UIScrollView costum pagination size
Well one clean & memory efficient approach is to have a UINavigationController
& UIToolBar
like so -
When the user taps on any button in the UIToolBar
invoke that particular viewController
by popping and pushing them.
I hope its clear that the look and feel can be achieved close to what you are showing in the image, I am talking about the functionality.
iOS : How to do proper paging in UIScrollView?
Paging scroll views alway page multiples of their frame size. So in your example paging is always +320.
This behavior is good if you have content portions matching the frame of the scroll view.
What you have to do, is giving your scroll view a width of 213 and set its clipsToBounds
property to NO
.
After that your scroll view pages exactly how you want and you see what's left and right outside the frame.
Additionally you have to do a trick to make this left and right area delegate touches to the scroll view.
It's greatly explained in this answer.
scrollview size with Autolayout: frame is 600x480 in compact/Any size class, bigger than iphone5?
Size classes (or any auto layout changes, for that matter) are not applied until after viewDidAppear
or viewDidLayoutSubviews
. You will need to move this code into one of those. You are seeing the frame of the view as it is loaded out of the Interface Builder document (xib or storyboard). You should never be checking frames until after those lifecycle events.
Unable to set frame correctly before viewDidAppear
Related Topics
Retain Cycle (Strong Reference) Fix for Custom Uitextfield
CSS Gradient Not Working on iOS
Redirect Nslog to File in Swift Not Working
Using Core Data, Icloud and Cloudkit for Syncing and Backup and How It Works Together
How to Delay a Method Call for 1 Second
iPhone - When to Calculate Heightforrowatindexpath for a Tableview When Each Cell Height Is Dynamic
Using Existing System Sounds in iOS App [Swift|
How to Split Filename from File Extension in Swift
Enable or Disable iPhone Push Notifications Inside the App
Adding Convenience Initializers in Swift Subclass
Getter VS Computed Property. What Would Warrant Using One of These Approaches Over the Other
Downloading Uiimage via Alamofireimage
Uiview Vertical Flip Animation
How to Remove an iOS App from the App Store
What Size Should Tabbar Images Be