Content of UIscrollview not updating, when changing orientation

穿精又带淫゛_ 提交于 2019-12-12 01:05:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!