Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
669 views
in Technique[技术] by (71.8m points)

iphone - dequeueReusableCellWithIdentifier behavior changed for prototype cells?

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView 
  dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] 
      initWithStyle:UITableViewCellStyleDefault 
      reuseIdentifier:CellIdentifier];
}

// Configure the cell...
return cell;

With this simple code??:

UITableViewCell *cell = [tableView 
  dequeueReusableCellWithIdentifier:@"Cell"];
return cell;

I saw this on this link:

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

Thank's in advance!

Arildo

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...