簡體   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