0

I have a tableview which displays an image, issue is images are of different quality and size ratio so when they are displayed, they are shown like belowenter image description here

my code on calling this is shown below

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }
        cell.textLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:20.0];
        cell.detailTextLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:15.0];
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.detailTextLabel.textColor = [UIColor whiteColor];
        cell.contentView.backgroundColor = [UIColor clearColor];
        cell.textLabel.backgroundColor = [UIColor clearColor];
        cell.detailTextLabel.backgroundColor = [UIColor clearColor];
        cell.backgroundColor = [UIColor clearColor];
        cell.imageView.contentMode = UIViewContentModeScaleAspectFill;

        Pupils *aPupil = [ArrayOfDisplayIDs objectAtIndex:indexPath.row];


        cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", aPupil.firstname,aPupil.secondname];
        cell.detailTextLabel.numberOfLines = 3;
        cell.detailTextLabel.text = [NSString stringWithFormat:@"%@: %@      Gender: %@ \n%@: %@   \n%@: %@", @"Class",aPupil.Class, aPupil.Gender, @"Date of Birth" ,aPupil.DOB, @"Date of Enrolment" ,aPupil.DateofEntry];
        cell.imageView.image = aPupil.picture;
    return cell;
 }

how can i keep these photos the same size no matter what.

so the picture is same size, same height, same width, or the text all starts in a straight line, just for neatness.

thanks

Display Name
  • 1,025
  • 2
  • 15
  • 34
  • Can you define "same size"? At the moment both images are restricted to filling the height of the cell, what do you want to achieve? It may be helpful to add a mockup of what you want the end result to be. – lucianomarisi Apr 27 '14 at 11:26

1 Answers1

0

Create a custom UITableviewCell and change the layoutSubviews method to set the cell's imageView.frame like in this answer:

https://stackoverflow.com/a/4866205/1014164

Community
  • 1
  • 1
cohen72
  • 2,830
  • 29
  • 44