【发布时间】:2018-11-22 11:23:10
【问题描述】:
我遇到了一个关于 UITableViews 的奇怪问题。我表格中的一些单元格位于屏幕的最右侧,除了前几个字符外,它无法阅读。当我滚动表格时,受影响的单元格会发生变化。我添加了几个屏幕截图,以帮助更好地了解我正在处理的内容。
我使用以下代码填充表格:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"NewCell";
NewProductCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
long row = [indexPath row];
cell.medicineLabel.text = [_medicineArray objectAtIndex:row];
if([[_medicineArray objectAtIndex:row] isEqual: @"Alfabetisch"]|| [[_medicineArray objectAtIndex:row] isEqual: @"Eerder besteld"]){
[cell setUserInteractionEnabled:NO];
}
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
_medicinceArray 是从网络服务器获取的字符串列表,我已经验证这不是问题的根源。
提前致谢。
【问题讨论】:
-
medicineArray 中可能有空字符串
-
不相关但将
long更改为NSInteger。 -
您可能需要包含您的 NewProductCell 代码才能获得正确的答案。
-
你用tableview注册了cell吗?或者更确切地说,您是如何注册的?另外,如果您将文本静态分配给标签而不是从数组中获取,会发生什么?
标签: ios objective-c uitableview uistoryboard