代码改变世界

iOS5.0中initWithFrame:(CGRect) reuseIdentifier:(NSString *)用法停用了。

2011-11-27 18:34  张智清  阅读(1943)  评论(0编辑  收藏  举报

在ios4.3时下列用法是可行的:

NSArray *nibfile = [[NSbound mainBundle] loadNibNames:@dcell" owner:self option:nil];

CGRect cellFrame = CGRectMake(0,0,300,30);

cell = [[UITableViewCell  alloc] initWithFrame:cellFrame reuseIdentifier:CellIdentifer] autorelease];

但是在iOS5.0之后initWithFrame方法的这一形态用法被停用了,据官方文档说,现在改用initWithStyle。具体如何使用呢?

cell = [[[UITableViewCell  alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

以备参考!!