Storyboard warning: prototype table cells must have reuse identifiers

前端 未结 11 1030
礼貌的吻别
礼貌的吻别 2020-12-07 19:36

I am getting this warning from storyboard - prototype table cells must have reuse identifiers.

I have renamed the identifier in the attributes inspector but it does

相关标签:
11条回答
  • 2020-12-07 19:58

    Since double-clicking this warning can lead to a bit of a wild goose chase (the specific UITableViewCell doesn't get selected), just wanted to add that while some of these warnings will auto-resolve, some will not.

    If you are confident you've tagged all your cells in Storyboard, rebuild the project - your warning may disappear (as did mine).

    0 讨论(0)
  • 2020-12-07 19:59

    Another way is to set the Table View 'Prototype Cells' property to zero in Attributes Inspector, if you are defining the cell using a .xib programatically.

    0 讨论(0)
  • 2020-12-07 20:00

    The identifier is the name you refer to in you .m file. When it is not filled it is not possible to reference the cell.

    0 讨论(0)
  • 2020-12-07 20:00

    This for setting reuse identifier by programmatically

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath*)indexPath 
    {
        static NSString *cellIdentifier = @"wot";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    
        if (!cell)
            cell = [[UITableViewCell alloc] initWithStyle: someStyle reuseIdentifier: cellIdentifier];
    
        return cell;
    }
    
    0 讨论(0)
  • 2020-12-07 20:02

    I've noticed that this error occurs when you have multiple prototype cells (in the tableview properties) and have not given all of them re-use identifiers.

    0 讨论(0)
  • 2020-12-07 20:14

    To shut up the warning you have to give a name to the cell identifier :

    enter image description here

    0 讨论(0)
提交回复
热议问题