I have a hierarchy like so
- UIView
- UITableView
- UIButton
By default swiping from a UIButton does not scroll the scroll view. I want to change this so it does.
I could do this by changing the UIButton
to a UILabel
and add a UITapGestureRecogniser
to it to effectively make a custom button.
Is there a way to do it keeping it as a UIButton?
-(void)moveUpView
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:n inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop
animated:YES];
}
Hope this may work
Create a duplicate UITableView
(with the same dataSource
and delegate
), but don't insert it anywhere into the view hierarchy; just add its panGestureRecognizer
to the UIButton
. Implement its delegate -scrollViewDidScroll:
method to set the original UITableView
's contentOffset
to that of the duplicate UITableView
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.