美文网首页
UITableView的一些小方法

UITableView的一些小方法

作者: 恶棍01 | 来源:发表于2017-12-08 14:49 被阅读0次

一,UITableView滚动到最后一行

NSIndexPath *indexpath = [NSIndexPath indexPathForRow:(self.msgArray.count -1) inSection:0];

[self.tableView scrollToRowAtIndexPath:indexpath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];

二、在block方法中刷新UITableView

dispatch_sync(dispatch_get_main_queue(), ^{

        [self.tableView reloadData];

});

三、获取是从哪个cell点击的按钮下标

- (NSIndexPath *)getIndexPath:(id)sender withTableView:(UITableView *)tableView

{

//这两段获取用户点击的是哪一个cell

        CGPoint buttonOriginInTableView = [sender convertPoint:CGPointZero                                            toView:tableView];

        return [tableView indexPathForRowAtPoint:buttonOriginInTableView];

}

四、UITableView点击取消选中状态

[tableView deselectRowAtIndexPath:indexPath animated:NO];

相关文章

网友评论

      本文标题:UITableView的一些小方法

      本文链接:https://www.haomeiwen.com/subject/fejkixtx.html