Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone : How to set ImageView's frame in table?

I have set imageView's frame in table using the following code.

  cell.imageView.image = [UIImage imageWithContentsOfFile:[[users objectAtIndex:indexPath.row] valueForKey:@"ImagePath"]];
  [cell.imageView setFrame:CGRectMake(5, 5, 10, 10)];

But image is displayed from the corner of the cell.

It does not changes the position or size.

what should I do ?

like image 967
Devang Avatar asked Jan 24 '26 07:01

Devang


2 Answers

You will not be able to change the cells imageView frame. Your best option would be to create a custom cell.

like image 125
WrightsCS Avatar answered Jan 26 '26 23:01

WrightsCS


You can change the frame of the cell by creating a subclass of UITableViewCell and overriding the layoutSubviews method.

In your subclass implementation of layoutSubviews, call super's implementation first and then modify the frame of imageView.

like image 24
number4 Avatar answered Jan 26 '26 22:01

number4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!