Get UIScrollView to scroll to the top

UPDATE FOR iOS 7 [self.scrollView setContentOffset: CGPointMake(0, -self.scrollView.contentInset.top) animated:YES]; ORIGINAL [self.scrollView setContentOffset:CGPointZero animated:YES]; or if you want to preserve the horizontal scroll position and just reset the vertical position: [self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0) animated:YES];

Stop UIWebView from “bouncing” vertically?

for (id subview in webView.subviews) if ([[subview class] isSubclassOfClass: [UIScrollView class]]) ((UIScrollView *)subview).bounces = NO; …seems to work fine. It’ll be accepted to App Store as well. Update: in iOS 5.x+ there’s an easier way – UIWebView has scrollView property, so your code can look like this: webView.scrollView.bounces = NO; Same goes for WKWebView.

Is it possible for UIStackView to scroll?

In case anyone is looking for a solution without code, I created an example to do this completely in the storyboard, using Auto Layout. You can get it from github. Basically, to recreate the example (for vertical scrolling): Create a UIScrollView, and set its constraints. Add a UIStackView to the UIScrollView Set the constraints: Leading, … Read more

UIScrollView scroll to bottom programmatically

You can use the UIScrollView’s setContentOffset:animated: function to scroll to any part of the content view. Here’s some code that would scroll to the bottom, assuming your scrollView is self.scrollView: Objective-C: CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height – self.scrollView.bounds.size.height + self.scrollView.contentInset.bottom); [self.scrollView setContentOffset:bottomOffset animated:YES]; Swift: let bottomOffset = CGPoint(x: 0, y: scrollView.contentSize.height – scrollView.bounds.height + scrollView.contentInset.bottom) … Read more

UIScrollView Scrollable Content Size Ambiguity

Updated Nowadays, Apple realized the problem we solved many years ago (lol_face) and provides Content Layout Guide and Frame Layout Guide as part of the UIScrollView. Therefore you need to go through the following steps: Same as original response below; For this contentView, set top, bottom, left, and right margins to 0 pinning them to … Read more

How can I make a UITextField move up when the keyboard is present – on starting to edit?

You will only need a ScrollView if the contents you have now do not fit in the iPhone screen. (If you are adding the ScrollView as the superview of the components just to make the TextField scroll up when keyboard comes up, then it’s not needed.) The standard way to prevent the TextFields from being … Read more