【发布时间】:2016-08-05 16:39:43
【问题描述】:
我用自己的自定义UITableViewCell 创建了UITableView,我有一个UITableViewCell 的.xib 文件,我的应用程序语言是从右到左我想在单元格右侧显示UIImageView 并自定义我的细胞用于此目的。但是在UITableView更改表格视图模式并选择单元格时,我的图像视图显示在单元格左侧并更改了此位置,问题出在哪里?
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
PersonnelCell *cell = (PersonnelCell *)[self.tableView dequeueReusableCellWithIdentifier:@"PersonnelCell"];
NSMutableArray *cells = [[NSMutableArray alloc] init];
if (cell == nil) {
cell = [[PersonnelCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"PersonnelCell"];
}
cell.cellImage.image = [UIImage imageNamed:@"logo.png"];
NSArray *personnels = [[PersonelList sharedList] allPersonel];
if (tableView == self.searchDisplayController.searchResultsTableView) {
NSArray *a = [[NSArray alloc] init];
a = [self.resultData firstObject];
NSString *s = [[a objectAtIndex:0] stringByAppendingString:@" "];
s = [s stringByAppendingString: [a objectAtIndex:1]];
cell.nameLabel.text = s;
if ([[a objectAtIndex:2] isKindOfClass:[UIImage class]]) {
cell.cellImage.image=[a objectAtIndex:2];
}
return cell;
}
【问题讨论】:
-
显示您的代码和模拟器快照。
-
可能是因为tableview重用了单元格,所以第二次分配单元格时使用的是默认单元格。
标签: ios objective-c uitableview right-to-left