Ari*_*ior 9 iphone cells storyboard tableview ios5
在iOS5中,在故事板上使用ARC和原型单元格用于tableView,我可以替换下面的代码:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
// Configure the cell...
return cell;
Run Code Online (Sandbox Code Playgroud)
有了这个简单的代码??:
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"Cell"];
return cell;
Run Code Online (Sandbox Code Playgroud)
我在这个链接上看到了这个:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
提前致谢!
Arildo
当然,你的代码是正确的,故事板自动分配新的单元格,这段代码工作得很好:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
RoadbookCell *cell = (RoadbookCell *)[tableView dequeueReusableCellWithIdentifier:@"RoadbookCell"];
//Configure cell
//[cell.lab1 setText:@"Test"];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9724 次 |
最近记录: |