UITableView 滚动到指定行cell
2015-11-15 00:33
423 查看
1.滚动到指定的cell
设置需要滚动到的cell的NSIndexPath[NSIndexPath indexPathForRow: inSection:]
滚动到指定cell
[self.tableview selectRowAtIndexPath:[NSIndexPath indexPathForRow:arc4random_uniform(29) inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
2.与1类似的方法
[self.tableview scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:temp inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
3.滚动到最近选中的cell(选中的cell消失在屏幕中,触发事件可以滚动到选中的cell)
[self.tableview scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:YES];
1,2,3用到的枚举
typedef NS_ENUM(NSInteger, UITableViewScrollPosition) {
UITableViewScrollPositionNone,
UITableViewScrollPositionTop,
UITableViewScrollPositionMiddle,
UITableViewScrollPositionBottom
};
设置需要滚动到的cell的NSIndexPath[NSIndexPath indexPathForRow: inSection:]
滚动到指定cell
[self.tableview selectRowAtIndexPath:[NSIndexPath indexPathForRow:arc4random_uniform(29) inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
2.与1类似的方法
[self.tableview scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:temp inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
3.滚动到最近选中的cell(选中的cell消失在屏幕中,触发事件可以滚动到选中的cell)
[self.tableview scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:YES];
1,2,3用到的枚举
typedef NS_ENUM(NSInteger, UITableViewScrollPosition) {
UITableViewScrollPositionNone,
UITableViewScrollPositionTop,
UITableViewScrollPositionMiddle,
UITableViewScrollPositionBottom
};
相关文章推荐
- 基于jquery实现一个滚动的分步注册向导-附源码
- 超级经典一套鼠标控制左右滚动图片带自动翻滚
- 可左右平滑滚动的产品展示效果
- WinForm实现仿视频播放器左下角滚动新闻效果的方法
- JavaScript控制网页平滑滚动到指定元素位置的方法
- jquery实现网页的页面平滑滚动效果代码
- jquery滚动特效集锦
- jQuery实现平滑滚动到指定锚点的方法
- jquery实现的鼠标下拉滚动置顶效果
- jQuery实现自动滚动到页面顶端的方法
- jQuery网页右侧广告跟随滚动代码分享
- jQuery实现响应鼠标滚动的动感菜单效果
- jquery实现仿新浪微博评论滚动效果
- jquery.blockUI.js上传滚动等待效果实现思路及代码
- jQuery实现滚动切换的tab选项卡效果代码
- jquery实现Li滚动时滚动条自动添加样式的方法
- JS实现兼容性较好的随屏滚动效果
- JS实现图片无间断滚动代码汇总
- JS实现的新浪微博大厅文字内容滚动效果代码
- JavaScript 无缝上下左右滚动加定高定宽停顿效果(兼容ie/ff)