我尝试在 imageview 中加载动态图像,在 label 中加载文本,它在模拟器和 ios 设备中都可以正常工作。(见下面的代码)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ImageCell *cell = (ImageCell *)[self.TestTable dequeueReusableCellWithIdentifier:@"ImageCell"];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ImageCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
}
else
{
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ImageCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
}
cell.textlabels.text=@"Cable and Hose Carriers";
cell.ProductsImages.image = [UIImage imageNamed:@"cool.jpg"];
return cell;
}
但是,如果我尝试在自定义 tableview 单元格中的 uitextview 中加载数据,tableview 在 ios 设备中滚动不流畅(口吃),但在模拟器中工作正常。请建议我做得更好。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ImageCell *cell = (ImageCell *)[self.TestTable dequeueReusableCellWithIdentifier:@"ImageCell"];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ImageCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
}
else
{
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ImageCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
}
cell.ProductsDetailsTextView.delegate = self;
cell.ProductsDetailsTextView.text=[Descriptions objectAtIndex:indexpath.row];
return cell;
}