首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PFQueryTableViewController跳转

PFQueryTableViewController跳转
EN

Stack Overflow用户
提问于 2014-12-04 06:47:56
回答 1查看 120关注 0票数 0

编辑1

要明确的是,self loadObjects不是我的方法--它是解析提供的PFQueryTableViewController类上的一个方法,用于提取新数据。

我怀疑这可能是由表格绘制代码引起的,因为桌面视图被配置为自动调整其高度。

下面是表格的绘图代码:

代码语言:javascript
复制
- (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秒运行一次,调用:

代码语言:javascript
复制
[self loadObjects]

若要获取任何新对象,或已更改为已发生的对象,请执行以下操作。

所有这些都很好,但是如果我在loadObjects被调用时滚动到表视图的一半,页面就会跳回顶部。即使没有新的或更改的数据可用。

在我开始研究如何捕捉重装并迫使表保持原状之前,有什么简单的方法可以绕过这个问题吗?

谢谢

加雷斯

EN

回答 1

Stack Overflow用户

发布于 2014-12-08 20:36:30

调用loadObjects时,从一开始就加载对象。在这里,你又得到了第一个结果。

尝试将[self loadObjects];更改为[self.tableView reloadData];

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27287895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档