29,030
社区成员
发帖
与我相关
我的任务
分享
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40.0f;
}
这个方法能修改cell的高度。
另外, 如果cell高度不同。 可以不复用cell,如果数据不多的话。
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:2 inSection:0];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
取出来的cell是nil,是不是tableview还没生成?这两行代码应该加在哪里?UITableViewCell *myCell = [_tableView cellForRowAtIndexPath:indexPath]; //选取某个cell
cellForRowAtIndexPath 返回的是一个UITableViewCell//cell位置设置
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
//选取某个cell
[_tableView cellForRowAtIndexPath:indexPath];
//选中高亮
[_tableView selectRowAtIndexPath:indexPath
animated:YES
scrollPosition:UITableViewScrollPositionMiddle];
//滚动视图
[_tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
//刷新列表
[_tableView reloadData];
不知道你需要的是不是这个?