iOS Question Objective C to B4i Set Screen Orientation

astronald

Active Member
Licensed User
Longtime User
After IOS 16 canot change screen orientation with

Orientation:
no.Initialize ("UIDevice").RunMethod ("currentDevice", Null).SetField ("orientation", 3)


I found this code can anywhere help me pass to B4X

Objective-C:
        if #available(iOS 16.0, *) {
            DispatchQueue.main.async {
                let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
                self.setNeedsUpdateOfSupportedInterfaceOrientations()
                self.navigationController?.setNeedsUpdateOfSupportedInterfaceOrientations()
                windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: .landscape)) { error in
                    print(error)
                    print(windowScene?.effectiveGeometry ?? "")
                }
            }
        }else{
            UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
        }


Thanks for your time.
 

astronald

Active Member
Licensed User
Longtime User
Can someone help me?
the window loads very badly, i try with inline objc but fire error on first line.
 
Upvote 0

Filippo

Expert
Licensed User
Longtime User
Can someone help me?
the window loads very badly, i try with inline objc but fire error on first line.
Please read more here .
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The last time I tried it, it didn't work.

For a simple layout, without text input, you can do something like in the attached project.

1681795675852.png


Note that the page is set to full screen in the main module.
 

Attachments

  • Project.zip
    8.7 KB · Views: 170
Upvote 0
Top