HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – UIScrollView旋转后不允许滚动或交互大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;

方法,我有代码重新定位和调整滚动视图的大小,因为应用程序随设备一起旋转.我使用以下代码执行此操作:

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{

    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:0.5f];

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
         //landscape
    [mT.buttonScroll setFrame:CGRectMake(0,544,1024,160)];

    }else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
        //landscape
    [mT.buttonScroll setFrame:CGRectMake(0,160)];

    }else if (toInterfaceOrientation == UIInterfaceOrientationPortrait){
       //portrait
    [mT.buttonScroll setFrame:CGRectMake(0,800,768,160)];

    }else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
      //portrait
    [mT.buttonScroll setFrame:CGRectMake(0,160)];

    }
}

一切都正常旋转,但是一旦我再次旋转滚动视图就完全无法触及.无法滚动或触摸其中的任何按钮.然后,如果我旋转回上一个视图,触摸会返回,依此类推.有谁知道它为什么这样做?

解决方法

更改框架一切都很好但是当涉及到UIScrollViews时,它的contentSize会产生重大影响.更改方向时需要设置contentSize.您可以通过在更改方向时添加类似的内容来完成此操作.

[mT.buttonScroll setContentSize:CGSizeMake(width,height)];

我假设mT.buttonScroll是某种UIScrollView.

这里发生的是您将内容区域的大小重置为您想要的大小.你可以在这里修改宽度和高度.

希望这有帮助,如果不给我们评论,我会尝试帮助.

大佬总结

以上是大佬教程为你收集整理的ios – UIScrollView旋转后不允许滚动或交互全部内容,希望文章能够帮你解决ios – UIScrollView旋转后不允许滚动或交互所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: