I have a UIYableView and I keep images in that tableview, I change the UIImageView size each time I rotate the phone. I check the self.interfaceOrientation in the tableView:cell:forIndexpath and decide what sizes to give to the imageview.And I off cource reload the tableview each time rotation occurs. But after rotation the images seem to get mixed. I mean I get a part of an image on another image.What would be the best approach to fix this?
Edit:Added some code
In tableview:cell:forIndexPath method I do the following:
...............
NSUIinteger row=indexPath.row;
UIImageView *imageView=[[UIIMage alloc]initWithImage:[images ojectAtIndex:row]];
if(self.interfaceOrientation==UIInterfaceOrientationPortrait)
imageView.Frame.Size=CGSizeMake(320.0,460.0);
else
imageView.Frame.Size=CGSizeMake(480.0,300.0);
imageView.contentMode=UIContentModeAspectFit;
[cell.contentView addSubView:imageView];
in the tableview:height:forIndexPath method:
double height;
if(self.interfaceOrientation==UIInterfaceOrientationPortrait)
height=460;
else
height=300;
return height;
I return the width of the row the same way.
First, are you doing any drawing (UIKit) calls on background threads? That’s the most common cause of this kind of drawing corruption.
Next, why are you doing a
reloadDataafter rotation? That shouldn’t be necessary if you’re just resizing things. What kinds of images are these? Autoresizing will generally do what you want, and if not, you can re-layout the cells without reloading them.I strongly suspect background operations here, but if not, then I would suspect that your
cellForIndexPath:is not returning valid cells after rotation, probably an issue with how you set the imageView.