修改1
要清楚,[self loadObjects]不是我的方法,它是由parse提供的PFQueryTableViewController类的一个方法,用于提取新数据。
我怀疑这可能是由表绘图代码引起的,因为tablecellview配置为自动调整它的高度。
以下是表格绘图代码:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object
{
//Setup estimated heights and auto row height
self.tableView.estimatedRowHeight = 68.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
//Give the cell a static identifier
static NSString *cellIdentifier;
socialPost* post = object;
//Check to see what sort of cell we should be creating, text, image or video
if (object[@"hasImage"] != nil) {
cellIdentifier = @"posts_with_image";
} else {
cellIdentifier = @"posts_no_image";
}
//Create cell if needed
hashtagLiveCellView *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[hashtagLiveCellView alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
}
// Configure the cell to show our imformation, loading video and images if needed
cell.postTitle.text = [NSString stringWithFormat:@"@%@",object[@"userName"]];
cell.postText.text = [NSString stringWithFormat:@"%@",
object[@"text"]];
[cell.userImage setImageWithURL:[NSURL URLWithString:post.userImageURL]];
[cell.postImage setImageWithURL:[NSURL URLWithString:post.imageURL]];
//Set ID's on the custom buttons so we know what object to work with when a button is pressed
cell.approveButtonOutlet.stringID = object.objectId;
[cell.approveButtonOutlet addTarget:self action:@selector(approvePostCallback:) forControlEvents:UIControlEventTouchUpInside];
cell.deletButtonOutlet.stringID = object.objectId;
[cell.deletButtonOutlet addTarget:self action:@selector(deletePostCallback:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
原始
我有一个PFQueryTableViewController,我正在使用parse加载对象。
我有一个计划任务设置为每20秒运行一次,调用:
[self loadObjects]
获取任何新对象,或者对已发生的对象进行任何更改。
一切正常,但如果在调用loadObjects时我在tableview中间向下滚动,页面会跳回到顶部。即使没有可用的新数据或更改数据。
在开始研究hacky方法来捕捉重载并迫使表保持原状之前,有没有一个简单的方法呢。
由于
加雷
答案 0 :(得分:0)
当您调用loadObjects
时,您从开始加载对象。那里再次获得第一批结果。
尝试将[self loadObjects];
更改为[self.tableView reloadData];
。