Search code examples
iosobjective-cuitableviewparse-platformpfquerytableviewcontrolle

Custom init for TableView from storyboard


Tried to search answer on google and stackoverflow but stuck. I am using https://parse.com/docs/ios/api/Classes/PFQueryTableViewController.html to fill up data with my objects. Everything seems nice I got correct data for this table view

But I want to use my storyboard cell, but this seems I made wrong init.

    - (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;
}

And here is code for 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;

}

Please help me to achieve how to display my cell


Solution

  • I resolved it, first of all I fixed init for view controller, I called comment Vic from storyboard and then recreated my controller in storyboard after this I achieved custom pfquery cell