Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

supportedInterfaceOrientations called on all iPhones except 6+

On my iPhone app I have it restricted to portrait only under the project targets deployment info

There is one page that I want only in landscape and I use the supportedInterfaceOrientations method to obtain that.

Standard implementation:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.Landscape
    }

It works perfectly on all iPhone devices and iOS version except for iPhone 6+. The supportedInterfaceOrientations method is never called.

I cant find any reason why this might be affecting just the iPhone 6+, any tips would be greatly apreciated.

like image 443
JLoewy Avatar asked Oct 02 '15 01:10

JLoewy


1 Answers

you can try this code it works for me

// you have to import foundation
import Foundation

class YourViewController : UIViewController {
    var device = self.platform()

     override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(true)

     if device.lowercaseString.rangeOfString("iphone6plus") != nil {
     supportedInterfaceOrientations()
    }

    }

    // add this method to your view controller
    func platform() -> String {
            var sysinfo = utsname()
            uname(&sysinfo) // ignore return value
            return NSString(bytes: &sysinfo.machine, length: Int(_SYS_NAMELEN), encoding:
                NSASCIIStringEncoding)! as String
        }

Please note that this will not run on the simulator but will run perfectly on the actual device.

like image 139
OverD Avatar answered Nov 04 '22 01:11

OverD