编辑1
要明确的是,self loadObjects不是我的方法--它是解析提供的PFQueryTableViewController类上的一个方法,用于提取新数据。
我怀疑这可能是由表格绘制代码引起的,因为桌面视图被配置为自动调整其高度。
下面是表格的绘图代码:
- (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,它是用解析中的对象加载的。
我的计划任务设置为每20秒运行一次,调用:
[self loadObjects]若要获取任何新对象,或已更改为已发生的对象,请执行以下操作。
所有这些都很好,但是如果我在loadObjects被调用时滚动到表视图的一半,页面就会跳回顶部。即使没有新的或更改的数据可用。
在我开始研究如何捕捉重装并迫使表保持原状之前,有什么简单的方法可以绕过这个问题吗?
谢谢
加雷斯
发布于 2014-12-08 20:36:30
调用loadObjects时,从一开始就加载对象。在这里,你又得到了第一个结果。
尝试将[self loadObjects];更改为[self.tableView reloadData];。
https://stackoverflow.com/questions/27287895
复制相似问题