Scrolling with two fingers with a UIScrollView

In SDK 3.2 the touch handling for UIScrollView is handled using Gesture Recognizers. If you want to do two-finger panning instead of the default one-finger panning, you can use the following code: for (UIGestureRecognizer *gestureRecognizer in scrollView.gestureRecognizers) { if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { UIPanGestureRecognizer *panGR = (UIPanGestureRecognizer *) gestureRecognizer; panGR.minimumNumberOfTouches = 2; } }

Disabling automatic scrolling of UITableView when editing UITextField inside UITableViewCell

The autoscroll-behavior is located in the UITableViewController functionality. To disable the automatic scrolling I found two ways: Use instead of the UITableViewController simply a UIViewController – set the datasource and delegate on your own. Override the viewWillAppear method and don’t call [super viewWillAppear: animated] With both solution you disable not only the Autoscroll, but also … Read more

UIButton touch is delayed when in UIScrollView

Jeff’s solution wasn’t quite working for me, but this similar one does: http://charlesharley.com/2013/programming/uibutton-in-uitableviewcell-has-no-highlight-state In addition to overriding touchesShouldCancelInContentView in your scroll view subclass, you still need to set delaysContentTouches to false. Lastly, you need to return true rather than false for your buttons. Here’s a modified example from the above link. As commenters suggested, it … Read more

How to scroll UITableView to specific position

it should work using – (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated using it this way: NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [yourTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; atScrollPosition could take any of these values: typedef enum { UITableViewScrollPositionNone, UITableViewScrollPositionTop, UITableViewScrollPositionMiddle, UITableViewScrollPositionBottom } UITableViewScrollPosition;

Keep uitableview static when inserting rows at the top

There’s really no need to sum up all rows height, the new contentSize after reloading the table is already representing that. So all you have to do is calculate the delta of contentSize height and add it to the current offset. … CGSize beforeContentSize = self.tableView.contentSize; [self.tableView reloadData]; CGSize afterContentSize = self.tableView.contentSize; CGPoint afterContentOffset = … Read more

What’s the UIScrollView contentInset property for?

It sets the distance of the inset between the content view and the enclosing scroll view. Obj-C aScrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 7.0); Swift 5.0 aScrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 7.0) Here’s a good iOS Reference Library article on scroll views that has an informative screenshot (fig 1-3) – I’ll replicate … Read more

automaticallyAdjustsScrollViewInsets not working

I think that automaticallyAdjustsScrollViewInsets only works when your controllers view is a UIScrollView (a table view is one). You’re problem seems to be that your controller’s view is a regular UIView and your UITableView is just a subview, so you’ll have to either: Make the table view the “root” view. Adjust insets manually: UIEdgeInsets insets … Read more