Je veux montrer l'image dans la cellule au milieu de chaque tableView de celui-ci pour que la méthode tableView de cellForRowAtIndexPath je peux personnaliser chaque cellule comme à mon besoinModifier la position de l'image dans tableView dans iphone?
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:
[[NSBundle mainBundle]
pathForResource:@"phone"
ofType:@"png"]];
infoView = [[UIView alloc]initWithFrame:cell.frame];
lblCell1 = [[[UILabel alloc]initWithFrame:CGRectMake(0, 0, (cell.frame.size.width)/3, cell.frame.size.height)]autorelease];
lblCell1.backgroundColor = [UIColor grayColor];
[infoView addSubview:lblCell1];
imgCell1 = [[[UIImageView alloc]initWithFrame:CGRectMake((cell.frame.size.width)/3, cell.frame.size.width, 30, (cell.frame.size.height)/2)]autorelease];
[infoView addSubview:imgCell1];
lblCell2 = [[[UILabel alloc]initWithFrame:CGRectMake(((cell.frame.size.width)/3)+30, 0, cell.frame.size.width,(cell.frame.size.height)/2)]autorelease];
lblCell2.backgroundColor = [UIColor lightGrayColor];
[infoView addSubview:lblCell2];
lblCell3 = [[[UILabel alloc]initWithFrame:CGRectMake((cell.frame.size.width)/3, (cell.frame.size.height)/2, cell.frame.size.width, (cell.frame.size.height)/2)]autorelease];
lblCell3.backgroundColor = [UIColor brownColor];
[infoView addSubview:lblCell3];
[cell.contentView addSubview:infoView];
//[cell.contentView addSubview:imgCell1];
//[cell.contentView addSubview:lblCell2];
//[cell.contentView addSubview:lblCell3];
Player *doc = [[Player alloc]init];
NSMutableArray* reversedArray = [[NSMutableArray alloc] initWithArray:[[[[NSArray alloc] initWithArray: _data] reverseObjectEnumerator] allObjects]];
doc = [reversedArray objectAtIndex:indexPath.row];
lblCell1.text = doc.name;
lblCell2.text = doc.email;
lblCell3.text = doc.phone;
imgCell1.image = backgroundImage;
[imgCell1 sizeToFit];
// cell.imgCell1.image = [UIImage imageNamed:@"phone.png"];
return cell;
mais l'image n'est pas définie dans le cadre de UIImageView. où je me trompe & ce que je fais pour afficher l'image au milieu de table vue chaque cellule.
c'est le même travail que mon code signifie que l'image apparaît à l'endroit où ma ligne n'est pas montrée signifie si dans tableview pas. de lignes est supposé 5 alors l'image montre à la ligne a commencé avec l'index. 10 & va jusqu'à 14 mais pas au bon endroit. que puis-je faire pour définir l'image au bon endroit. –
Réglez-vous correctement le cadre de l'image en utilisant CGRectMake? – Bourne
Vous devez également implémenter la méthode height pour les cellules. Google sur la façon de définir la hauteur personnalisée. – Bourne