For (UIView *cellview in cell.subviews) {
[Cellview Removefromsuperview];
}
Avoid problems with pictures
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath
{
static NSString *cellidentifier = @ "Cell";
UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier];
if (cell = = nil) {
cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];
Cell.selectionstyle = Uitableviewcellselectionstylenone;
}else{
For (UIView *cellview in cell.subviews) {
[Cellview Removefromsuperview];
}
}
if (indexpath.row%2 = = 0) {
Cell.backgroundcolor =[uicolor Redcolor];
}
Cell.backgroundcolor =[uicolor Clearcolor];
Nsdictionary *dict = [_resultarray objectAtIndex:indexPath.row];
Create Avatar
Uiimageview *photo;
if ([[Dict objectforkey:@ "name"]isequaltostring:@ "RHL"]) {
I
Photo = [[Uiimageview alloc]init];//withframe:cgrectmake (width-width*40/320, Cell.bounds.size.height, width*30/320, width*30/320)];
Photo.layer.masksToBounds =yes;
Photo.layer.cornerRadius = 15;
[Cell Addsubview:photo];
[Photo mas_makeconstraints:^ (Masconstraintmaker *make) {
Make.size.mas_equalTo (Cgsizemake (30, 30));
Make.right.equalTo (@ (-10));
Make.bottom.equalTo (@ (-20));
}];
Photo.image = [UIImage imagenamed:@ "headimage10.jpg"];
Photo.backgroundcolor =[uicolor Yellowcolor];
if ([[Dict objectforkey:@ "content"] isequaltostring:@ "0"]) {
[Cell addsubview:[self yuyinview:1 from:yes withIndexRow:indexPath.row withposition:width*25/320]];
}else{
[Cell addsubview:[self bubbleview:[dict objectforkey:@ "content"] from:yes withposition:width*65/320]];
}
}else{
Each other
Photo = [[Uiimageview alloc]initwithframe:cgrectmake (10,15,30,30)];
Photo.layer.masksToBounds =yes;
Photo.layer.cornerRadius = 15;
[Cell Addsubview:photo];
Photo.image = [UIImage imagenamed:@ "headimage2.jpg"];
Photo.backgroundcolor =[uicolor Blackcolor];
if ([[Dict objectforkey:@ "content"] isequaltostring:@ "0"]) {
[Cell addsubview:[self yuyinview:1 from:no withIndexRow:indexPath.row withposition:width*25/320]];
}else{
[Cell addsubview:[self bubbleview:[dict objectforkey:@ "content"] from:no withposition:width*65/320]];
}
}
return cell;
}
TableView Agent inside Add image