Yummypets / YPImagePicker

📸 Instagram-like image picker & filters for iOS
MIT License
4.31k stars 976 forks source link

Problem with iPad on rotation #550

Open nickeyzzz opened 4 years ago

nickeyzzz commented 4 years ago

Running example app on the emulator, start Image picker, then rotate. https://www.dropbox.com/s/6r0nbsrzie0gqog/Simulator%20Screen%20Shot%20-%20iPad%20Pro%20%289.7-inch%29%20-%202020-08-28%20at%2022.34.35.png?dl=0

nickeyzzz commented 4 years ago

It won't work correct as this won't be called on modern iPads: open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait } until you didn't set "Requires full screen" in General tab of your Target. https://stackoverflow.com/questions/35274428/supportedinterfaceorientations-not-called-in-ipad

If 'Requires full screen' setting from 'General' is enable, will allow the orientation delegate methods shouldAutorotate, preferredInterfaceOrientation, and supportedInterfaceOrientations to fire.

nickeyzzz commented 4 years ago

I think this can be added to documentation or the whole Picker requires some fixes for handling iPad rotations correct way.

StephanKornerTrihow commented 3 years ago

iPad Rotation on iPad does not work. Right side of picker is black. (version = XCode 12 release)

JQfCX

I tried something like the following inside YPImagePicker.swift, but without success.

Do you know how the landscape rotation can be done otherwise ?

open override var shouldAutorotate: Bool {
        return true
    }

    open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {

        super.viewWillTransition(to: size, with: coordinator)

        coordinator.animate(alongsideTransition: { (context) in
            guard let windowInterfaceOrientation = self.windowInterfaceOrientation else { return }

            if windowInterfaceOrientation.isLandscape {
                // activate landscape changes
                print("landscape now")
                print(UIScreen.main.bounds.height)
                print(UIScreen.main.bounds.width)
                self.view.frame = CGRect(x: 0.0, y: 0.0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
                self.view.setNeedsLayout()
                self.view.layoutSubviews()
            } else {
                // activate portrait changes
                print("portrait now")
                print(UIScreen.main.bounds.height)
                print(UIScreen.main.bounds.width)
                self.view.frame = CGRect(x: 0.0, y: 0.0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
                self.view.setNeedsLayout()
                self.view.layoutSubviews()
            }
        })
    }

    private var windowInterfaceOrientation: UIInterfaceOrientation? {
        if #available(iOS 13.0, *) {
            return UIApplication.shared.windows.first?.windowScene?.interfaceOrientation
        } else {
            return UIApplication.shared.statusBarOrientation
        }
    }
riazhazan commented 3 years ago

@StephanKornerTrihow Did you find any solution for this issue? @nickeyzzz

StephanKornerTrihow commented 3 years ago

no - not yet

Indeed, I observed that landscape rotation on iPhone is also error-prone (especially when in camera-mode). I am waiting on some input from the YPImagePicker cracks on this.

majid701 commented 3 years ago

I'm having the same issue on ipad, any idea on the fix or when it will be fixed?

fukemy commented 2 years ago

still get portrait in iPad. even parent screen is in landscape mode

mikemike396 commented 2 years ago

Any update on this? We are facing this same issue where the selection view is broken on iPad in landscape. If we enable requires full screen the issue is fixed. Seems to be outlined here that its not possible to support split screen multi-tasking with orientation locking -> https://stackoverflow.com/a/56267601/757503

fukemy commented 2 years ago

im using other lib that handle all better

mikemike396 commented 2 years ago

im using other lib that handle all better

Which one?

fukemy commented 2 years ago

im using other lib that handle all better

Which one? https://github.com/hyperoslo/ImagePicker

itbeyond commented 2 years ago

I am seeing the same issue and it is a show stopper for me. @fukemy the referenced other library dos not unfortunately have video support etc so reduces the functionality somewhat.