有解决这个问题的想法吗?
这是正确和错误的方式:
这是工作代码:
- (UITableViewCell *)[...] cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@try {
newsRow = ((NewsRowController *)[tableView dequeueReusableCellWithIdentifier:@"cell"]);
if (newsRow == nil) {
if ( [[Device GetModel] isEqualToString:@"iPad Simulator"] ||
[[Device GetModel] isEqualToString:@"iPad"])
[[NSBundle mainBundle] loadNibNamed:@"NewsRow_ipad" owner:self options:nil];
else [[NSBundle mainBundle] loadNibNamed:@"NewsRow" owner:self options:nil];
if ([tableArray count] > 0)
[newsRow setData:[tableArray objectAtIndex:indexPath.row]];
}
}
@catch (NSException * e) {
NSLog(@"a!!!!!");
}
return newsRow;
}
...但是因为在我的 3g 设备中,当我向上/向下滚动表格时速度很慢 ,我以这种方式更改了代码,将 Device check 插入 viewDidLoad 并将其传递:cellForRowAtIndexPath
NSArray *cRow;
@property (nonatomic, retain) NSArray *cRow;
[...]
@syntetize cRow;
- (void)viewDidLoad {
[...]
if ( [[Device GetModel] isEqualToString:@"iPad Simulator"]
||
[[Device GetModel] isEqualToString:@"iPad"])
cRow = [[[NSBundle mainBundle] loadNibNamed:@"NewsRow_ipad" owner:self options:nil] retain];
else cRow = [[[NSBundle mainBundle] loadNibNamed:@"NewsRow" owner:self options:nil] retain];
[...]
}
- (UITableViewCell *)[...] cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@try {
newsRow = ((NewsRowController *)[tableView dequeueReusableCellWithIdentifier:@"cell"]);
if (newsRow == nil) {
//
// ADDED CODE.
//
newsRow = [cRow objectAtIndex:0];
//
if ([tableArray count] > 0)
[newsRow setData:[tableArray objectAtIndex:indexPath.row]];
}
}
@catch (NSException * e) {
NSLog(@"a!!!!!");
}
return newsRow;
}
现在表格只显示了一行。如果我滚动,行会改变,但它只显示一行......有
什么问题?
有什么帮助吗?
谢谢,
一个