2011-12-27 3 views
1

J'ai besoin de redimensionner la même taille d'image dans uitableviewcell. J'utilise la même page, n'utilisant pas l'autre vue. J'ai tout placé et j'ai couru. Mais je ne pouvais pas placer correctement positionné comment faire cela. Merci d'avance. Voici le codeComment redimensionner l'image de cellule uitableview?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
} 
int count = 0; 
if(self.editing && indexPath.row != 0) 
    count = 1; 

if(indexPath.row == ([imarry count]) && self.editing) 
{ 
    cell.textLabel.text = @"ADD"; 
    cell.image= [UIImage imageNamed:@""]; 
    return cell; 
} 
cell.textLabel.text = [arry objectAtIndex:indexPath.row]; 
cell.image=[imarry objectAtIndex:(indexPath.row)]; 
return cell;  
} 


- (void)imagePickerController:(UIImagePickerController *)UIPicker didFinishPickingImage:(UIImage *)info editingInfo:(NSDictionary *)dictionary 
{ 
[UIPicker dismissModalViewControllerAnimated:NO]; 
[imarry insertObject:info atIndex:[imarry count]]; 
[Table reloadData]; 
NSLog(@"Uploaded image"); 
} 

image de l'image est

enter image description here

+0

Checkout ces suggestions: [SO post] (http://stackoverflow.com/questions/1055495/uitableviewcells-imageview-fit-to-40x40) Et ceci [post SO] (http://stackoverflow.com/ questions/2788028/how-do-i-make-uitableviewcells-imageview-a-fixed-size-pair-when-the-image-is-sm) – user523234

Répondre

2

propriété d'image est dépréciée dans iOS 3.0. Vous pouvez définir l'imageview de la cellule mais elle est en lecture seule, vous ne pouvez donc pas la redimensionner.

En ajoutant l'image personnalisée, vous pouvez résoudre votre problème.

+0

Si j'utilise une image personnalisée, lorsque je la défile rapidement, elle se chevauche. si nly je n'utilise pas ça. – akk

+1

commentez simplement la ligne de code qui vérifie "if (cell == nil)" dans votre "cellForRowAtIndexPath". – Reena

+0

donc il va créer une nouvelle cellule et il ne se chevauchera pas. – Reena

Questions connexes