UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath: Exception

后端 未结 9 2182
悲&欢浪女
悲&欢浪女 2021-01-03 19:15

i actually dont see my error:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *Cel         


        
9条回答
  •  旧巷少年郎
    2021-01-03 19:58

    Look here: Loading TableViewCell from NIB

    This is Apple's document for this exact subject.

    //This is assuming you have tvCell in your .h file as a property and IBOutlet
    //like so:
    TableViewController.h
    @property(nonatomic,retain) IBOutlet UITableViewCell *tvCell;
    //Data Source Method...
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    
    if (cell == nil) {
    
        [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];
    
        cell = tvCell;
    
        self.tvCell = nil;
    

    use the loadNibNamed:owner:options method to load a cell in a nib. Set the cell instance to your nib object, then set the nib object to nil.

    Read the rest of the documentation that I've linked to know how to access subviews inside your cell.

提交回复
热议问题