滚动视图中不包含横向图像的纵向

时间:2018-06-15 10:13:52

标签: swift uitableview uiscrollview scroll-paging

我是iOS开发的新手。 我真的很困惑如何完成这段代码。在我的工作中,我有3 - 4 ScrollView中的图像或视频。通过这种方式,我想表明,当图像或视频位于场景的中心并且我正在旋转屏幕时,这意味着纵向到横向,因此所选图像前面没有显示单个但显示2 - 3我的视图控制器中的图像 因此,如何仅以横向模式显示一个图像或视频一次 这意味着如何在中心设置scrollView图像。

非常感谢。

first portrait side show different images

second landscape show different images but i want only one image

like this only one image show in landscape

这是我的代码

override func viewWillAppear(_ animated: Bool) {
    imageView.autoresizesSubviews = true
    imageView.autoresizingMask = UIViewAutoresizing.flexibleWidth
    imageView.autoresizesSubviews = true
    imageView.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleHeight.rawValue)))


    imageView1.autoresizesSubviews = true
    imageView1.autoresizingMask = UIViewAutoresizing.flexibleWidth
    imageView1.autoresizesSubviews = true
    imageView1.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleHeight.rawValue)))
    func shouldAutorotate() -> Bool {
        if (UIDevice.current.orientation == UIDeviceOrientation.portrait ||
            UIDevice.current.orientation == UIDeviceOrientation.portraitUpsideDown ||
            UIDevice.current.orientation == UIDeviceOrientation.unknown) {
            return true
        }
        else {
            return false
        }
    }
    func supportedInterfaceOrientations() -> Int {
        return Int(UIInterfaceOrientationMask.portrait.rawValue) | Int(UIInterfaceOrientationMask.portraitUpsideDown.rawValue)
    }
}

0 个答案:

没有答案