UIScrollview content size when orientation changes

前端 未结 2 437
醉酒成梦
醉酒成梦 2021-01-19 05:01

I have a scrollview with pagination. In viewDidLoad i check if the current orientation is landscape then i set its contentsize\'s height 440

 if (UIDeviceOri         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 05:26

    Here it is a problem in your code. Why you are setting the frame size like this?? You have only the screen size of 320px width. And when it changes to landscape, height will be only 320px. But you are setting the scroll height as 480px and it goes out of the screen and start to scroll diagonally.

    self.scroll.frame = CGRectMake(0,0,480,480);
    

    Instead of that frame size, change like this

    self.scroll.frame = CGRectMake(0,0,480,320);
    

    And you need to set the content size depend on the content you are having inside the scroll view in either orientation.

提交回复
热议问题