dequeueReusableCellWithIdentifier behavior changed for prototype cells?

后端 未结 2 698
说谎
说谎 2020-12-20 15:35

In iOS5, using ARC and prototype cells for tableView on storyboard, can I replace the code below:

static NSString *CellIdentifier = @\"Cell\";

UITableViewCe         


        
相关标签:
2条回答
  • 2020-12-20 15:52

    This is the way Apple intends it to be used, but I recommend against it. There is a bug that causes dequeueReusableCellWithIdentifier to return nil when VoiceAssist is enabled on a device. That means your app will crash for users with this option turned on. This is still a problem as of iOS 5.1.1

    You can find more info and a workaround here:

    http://hsoienterprises.com/2012/02/05/uitableview-dequeuereusablecellwithidentifier-storyboard-and-voiceover-doesnt-work/

    The last paragraph has the work-around

    0 讨论(0)
  • 2020-12-20 16:02

    Sure, your code are right, storyboard automaticaly alloc new cells, this code work great:

     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {   
        RoadbookCell *cell = (RoadbookCell *)[tableView dequeueReusableCellWithIdentifier:@"RoadbookCell"];
    
        //Configure cell
        //[cell.lab1 setText:@"Test"];
    
        return cell;
    }
    
    0 讨论(0)
提交回复
热议问题