繁体   English   中英

自情节提要的TableView的自定义初始化

[英]Custom init for TableView from storyboard

试图在谷歌和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单元后在情节提要中重新创建了控制器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM