问题
Here's my problem.
Am Using a scrollview whose Frames I am changing when rotating the device.
I have 8 AsyncImageView on that scrollview. And the Images on AsyncImageView's are set by calling web services.
Project runs fine. Images on the AsyncImageView are loaded properly.
But when I rotate the device, AsyncImageViews shows no Images. I tried everything. No success. Then I used a trick. That is setting the scrollview content offset 1,0 when rotating in either direction.
And my project works fine. All the Images are shown properly. It looks my scrollview doesn't refresh when I change the rotation, But as I set its offset 1,0 ; It started showing Images on AsyncImageView properly. Is there any thing I missed regarding Uiscrollview?
I used
[self.scrollView setNeedsDisplay];
I applied few other things too, found on stackoverflow and google, nothing worked in my case. Please help.
Here's the code
//Magazine Images
//subview1 MAG Imaegs
[[asy_Array_Mag_sub1 objectAtIndex:0] setFrame:CGRectMake(59, 120, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:1] setFrame:CGRectMake(296, 120, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:2] setFrame:CGRectMake(576, 120, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:3] setFrame:CGRectMake(802, 176, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:4] setFrame:CGRectMake(57, 465, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:5] setFrame:CGRectMake(296, 383, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:6] setFrame:CGRectMake(570, 377, 136, 174)];
[[asy_Array_Mag_sub1 objectAtIndex:7] setFrame:CGRectMake(802, 486, 136, 174)];
[self.otlScrollView setFrame:CGRectMake(0, 0, 1024, 768)];
self.otlScrollView.contentSize = CGSizeMake(1024 * total_pages, 768);
[_otlSubView setFrame:CGRectMake(a1, 0, 1024, 768)];
[self.otlScrollView addSubview:_otlSubView];
[_otlSubView2 setFrame:CGRectMake(b1, 0, 1024, 768)];
[self.otlScrollView addSubview:_otlSubView2];
[_otlSubView3 setFrame:CGRectMake(c1, 0, 1024, 768)];
[self.otlScrollView addSubview:_otlSubView3];
[_otlScrollView setContentOffset:CGPointMake(1024 * (self.otlPageControl.currentPage), 0)];
来源:https://stackoverflow.com/questions/21859624/content-of-uiscrollview-not-updating-when-changing-orientation