3

When i load the page its normal pls check below image

enter image description here

and when i click on a row ,then the corresponding image is showing in different size , Please check the below image(when i click 1st and 2nd row)

enter image description here

Please help me to solve this issue. Here am using SDWebImage for lazy loading of images from url.

My code:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;    //count of section
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [names count];    //count number of row from counting array hear cataGorry is An Array
}



- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *MyIdentifier = @"service";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:MyIdentifier]
        ;
    }

    // Here we use the provided setImageWithURL: method to load the web image
    // Ensure you use a placeholder image otherwise cells will be initialized with no image

   // cell.imageView.frame=CGRectMake(5,10,50,60);
    cell.imageView.layer.cornerRadius=8.0;
    cell.imageView.clipsToBounds=YES;
    cell.imageView.autoresizingMask=UIViewAutoresizingFlexibleHeight;
    [cell.imageView setImageWithURL:[NSURL URLWithString:[imaages objectAtIndex:indexPath.row]]placeholderImage:[UIImage imageNamed:@"Placeholder.png"]];
    cell.textLabel.text = [names objectAtIndex:indexPath.row];
    cell.backgroundColor=[UIColor clearColor];

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 80;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}
Bangalore
  • 1,572
  • 4
  • 20
  • 50

2 Answers2

0

Solution

Clip image to subviews, and add autolayout to it.

[cell.contentView.superview setClipsToBounds:YES];

For custom cells, select your image and

enter image description here

Community
  • 1
  • 1
E-Riddie
  • 14,660
  • 7
  • 52
  • 74
0

If you reload the tableview when it finish loading, the image get the size that it was suppose to have

[self.tableview reloadData];
Aitul
  • 2,982
  • 2
  • 24
  • 52