此方法将禁用滚动tablevIEw以防止手动滚动.假设您有100行高度30,myvIEw是必须执行滚动的视图.在myvIEw上添加了滑动手势,设置滑动的方向很重要
– (无效)initialSetup
{
[self.tableVIEw setScrollEnabled:NO]; int numberOfRows=100;int rowHeight=30;myvIEw=[[UIVIEw alloc]initWithFrame:CGRectMake(280,30,numberOfRows*rowHeight)];[myvIEw setBackgroundcolor:[UIcolor yellowcolor]];[self.vIEw addSubvIEw:myvIEw];UISwipeGestureRecognizer *swipeDown=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(motion:)];[swipeDown setDirection:UISwipeGestureRecognizerDirectionDown];[myvIEw addGestureRecognizer:swipeDown];UISwipeGestureRecognizer *swipeUp=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(motion:)];[swipeUp setDirection:UISwipeGestureRecognizerDirectionUp];[myvIEw addGestureRecognizer:swipeUp];}@H_301_20@当swipeUp或swipeDown发生滑动手势时,将调用以下方法.
当方法接收到swipeUp手势时,它会将tablevIEw中最后一个当前可见的行滚动到顶部
当方法接收到swipeDown时,它会将第一个当前可见的行滚动到底部– (voID)动作:(UISwipeGestureRecognizer *)发送者
{if (sender.direction==UISwipeGestureRecognizerDirectionUp) { [self.tableVIEw scrollToRowAtIndexPath:[self.tableVIEw.indexPathsForVisibleRows objectAtIndex:[self.tableVIEw.indexPathsForVisibleRows count]-1] atScrollposition:UItableVIEwScrollpositiontop animated:YES];}else if(sender.direction==UISwipeGestureRecognizerDirectionDown){ [self.tableVIEw scrollToRowAtIndexPath:[self.tableVIEw.indexPathsForVisibleRows objectAtIndex:0 ] atScrollposition:UItableVIEwScrollpositionBottom animated:YES];}@H_301_20@}
总结以上是内存溢出为你收集整理的iPhone通过向外滑动表格视图来滚动UITableview全部内容,希望文章能够帮你解决iPhone通过向外滑动表格视图来滚动UITableview所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)