尝试在谷歌和stackoverflow上搜索答案,但被卡住了。我正在使用https://parse.com/docs/ios/api/Classes/PFQueryTableViewController.html用我的对象填充数据。一切看起来都很好我得到了正确的数据这个表视图
但我想使用我的故事板单元,但这似乎是我做了错误的初始化。
- (id)initWithPhoto:(PFObject *)aPhoto {
// self = [super initWithStyle:UITableViewStylePlain];
//self = [super init];
self = [super initWithClassName:@"photo"];
if (self) {
// The className to query on
self.parseClassName = kPAPActivityClassKey;
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = YES;
// The number of comments to show per page
// self.obcojectsPerPage = 30;
self.photo = aPhoto;
self.likersQueryInProgress = NO;
}
return self;
}
这是cellForRowAtIndexPath 的代码
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object {
[self.tableView registerClass:[KNPhotoDetailsCommentCell class] forCellReuseIdentifier:@"cell"];
static NSString *cellIdent = @"cell";
KNPhotoDetailsCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdent];
PFFile *userPhoto = userObject[@"profilePictureSmall"];
[cell.userPhoto setFile:userPhoto];
[cell.userPhoto loadInBackground];
[cell.imageView setFile:userPhoto];
[cell.imageView loadInBackground];
[self configureBasicCell:cell atIndexPath:indexPath];
NSString *userComment = object[@"content"];
cell.userComment.text = userComment;
cell.textLabel.text = userComment;
return cell;
}
请帮助我实现如何显示我的单元格
我不知道这个特定的Parse视图控制器的任何细节,但如果你在故事板中将你的单元格定义为原型单元格,你就不需要在代码中注册任何东西。只需确保在情节提要中为该单元格指定了重用标识符,并在cellForRowAtIndexPath
中使用相同的重用标识符。
我解决了它,首先我修复了视图控制器的init,我从故事板中调用了comment Vic,然后在故事板中重新创建了我的控制器,之后我实现了自定义的pfquery单元格