简体   繁体   English

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

[英]Custom init for TableView from storyboard

Tried to search answer on google and stackoverflow but stuck. 试图在谷歌和stackoverflow上搜索答案,但卡住了。 I am using https://parse.com/docs/ios/api/Classes/PFQueryTableViewController.html to fill up data with my objects. 我正在使用https://parse.com/docs/ios/api/Classes/PFQueryTableViewController.html使用对象填充数据。 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 这是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 请帮助我实现如何显示我的单元格

I don't know any details about this particular Parse view controller, but if you define your cell as a prototype cell in your storyboard, you don't need to register anything in code. 我不知道有关此特定Parse视图控制器的任何详细信息,但是如果您将您的单元格定义为情节提要中的原型单元格,则无需在代码中注册任何内容。 Just make sure you specify a reuse identifier for that cell in the storyboard and use the same reuse identifier inside cellForRowAtIndexPath . 只要确保您在情节提要中为该单元格指定一个重用标识符,并在cellForRowAtIndexPath内部使用相同的重用标识符即可。

我解决了这个问题,首先固定了视图控制器的init,然后从情节提要中调用了Comment Vic,然后在实现自定义pfquery单元后在情节提要中重新创建了控制器

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

相关问题 从 storyboard 自定义 UIViewController - Custom init of UIViewController from storyboard 情节提要tableview的领域初始化 - Realm init for storyboard tableview 如何从自定义 tableView 单元格创建自定义视图 storyboard 插座? - How to create a custom view storyboard outlet from a custom tableView cell? 从代码和情节提要中实例化自定义按钮-如何创建init方法 - Instantiate custom button from code and Storyboard - how to make an init method 通过其自定义init方法从情节提要中加载UIViewController - Loading UIViewController from storyboard through its custom init method 故事板中的UITableView-使用UITableViewStyleGrouped初始化 - UITableView from storyboard - init with UITableViewStyleGrouped 如何在Storyboard中使用ViewController的自定义init - How to use custom init of ViewController in Storyboard Swift 中 UIViewController 的自定义初始化,在 storyboard 中设置接口 - Custom init for UIViewController in Swift with interface setup in storyboard 如何在从界面构建器中的Storyboard场景实例化的视图控制器上调用自定义init? - How do I call a custom init on a view controller instantiated from a Storyboard scene in interface builder? 故事板中的自定义UIButton - Custom UIButton from storyboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM