ios Cutom表格视图单元格子视图彼此重叠
我已经创建了两个带有UILabel和UIImageView的自定义单元格。 即使我在它们之间添加了空格,UIImageView单元格也与UILabel单元格重叠。此外,我正在更新UIlabel单元格的框架,但它没有更新。我没有使用自动布局。有谁能给我一个解决办法吗ios Cutom表格视图单元格子视图彼此重叠,ios,uitableview,uiimageview,Ios,Uitableview,Uiimageview,我已经创建了两个带有UILabel和UIImageView的自定义单元格。 即使我在它们之间添加了空格,UIImageView单元格也与UILabel单元格重叠。此外,我正在更新UIlabel单元格的框架,但它没有更新。我没有使用自动布局。有谁能给我一个解决办法吗 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { Determi
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
DetermineCoatingCell *cell=[[NSBundle mainBundle] loadNibNamed:@"DetermineCoatingCell" owner:self options:nil][0];
float cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
NSDictionary *option =[arrOptions objectAtIndex:indexPath.row];
if (is_iPad) {
// float yValue=(cellHeight/2)-10;
lblTable= [[UILabel alloc]initWithFrame:CGRectMake(30, 5, 590, cellHeight)];
lblTable.font=[UIFont systemFontOfSize:30];
lblTable.numberOfLines=0;
lblTable.textColor=[UIColor colorWithRed:63.0/255.0f green:126.0/255.0f blue:199.0/255.0f alpha:1.0];
lblTable.textAlignment=NSTextAlignmentLeft;
} else {
// float yValue=(cellHeight/2)-5;
if (![option[@"CoatingImage"] isEqualToString:@""]) {
cell.imgView.tag = indexPath.row;
cell.imgView.userInteractionEnabled = YES;
UITapGestureRecognizer *tapgesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imgViewTapped:)];
tapgesture.numberOfTapsRequired = 1;
tapgesture.view.tag = indexPath.row;
tapgesture.cancelsTouchesInView = NO;
// [tapgesture setValue:[NSString stringWithFormat:@"%ld",indexPath.row] forKey:@"Tag"];
[cell.imgView addGestureRecognizer:tapgesture];
NSString *key = [[option valueForKey:@"CoatingImage"] MD5Hash];
NSData *data = [FTWCache objectForKey:key];
if (data) {
UIImage *image = [UIImage imageWithData:data];
cell.imageView.image=image;
} else {
[WebImageOperations processImageDataWithURLString:[option valueForKey:@"CoatingImage"] andBlock:^(NSData *imageData) {
[FTWCache setObject:imageData forKey:key];
UIImage *image = [UIImage imageWithData:imageData];
dispatch_async(dispatch_get_main_queue(), ^{
cell.imageView.image=image;
});
}];
}
} else {
CGRect framelbl = CGRectMake(0,0, cell.lblTitle.frame.size.width,cell.lblTitle.frame.size.height);
NSLog(@"%@",NSStringFromCGRect(framelbl));
[cell.lblTitle setFrame:framelbl];
}
}
cell.lblTitle.text=[NSString stringWithFormat:@"%@",[option valueForKey:@"AnswerOptionText" ]];
cell.lblTitle.textColor=[UIColor colorWithRed:63.0/255.0f green:126.0/255.0f blue:199.0/255.0f alpha:1.0];
NSLog(@"lblTableText %@",lblTable.text);
if(selectedPath.row == indexPath.row && selectedPath.section == indexPath.section)
{
cell.backgroundColor = [UIColor colorWithRed:227.0/255.0f green:227.0/255.0f blue:227.0/255.0f alpha:1.0];;
} else {
cell.backgroundColor = [UIColor clearColor];
}
return cell;
}
如果确定不在表视图中使用autolayout,请研究表视图委托方法-[id tableView:heightForRowAtIndexPath:]: :
您需要确定哪一行对应于图像视图单元格,哪一行对应于标签单元格,然后返回适当的高度。显示单元格子类中的布局代码以放置图像和标签。框架设置在哪里?如果使用自动布局,则不允许手动更改框架!我没有使用自动布局@LUK2302关于“在它们之间添加空间”的代码在哪里?