ios开发之--令UITableView滚动到指定位置

这个应用场景还是挺多的,代码如下:

//获取到需要跳转位置的行数
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:10 inSection:0];

//滚动到其相应的位置
[[self tableView] scrollToRowAtIndexPath:scrollIndexPath
        atScrollPosition:UITableViewScrollPositionTop animated:YES];

以下枚举决定滚动到指定位置的哪个位置

typedef NS_ENUM(NSInteger, UITableViewScrollPosition) {
    UITableViewScrollPositionNone,
    UITableViewScrollPositionTop,    
    UITableViewScrollPositionMiddle,   
    UITableViewScrollPositionBottom
};    

猜你喜欢

转载自www.cnblogs.com/hero11223/p/9237205.html
今日推荐