Search code examples
iosxcodeswiftorientationdevice-orientation

instance member of 'currentDevice' cannot be used on type


I'm making a video player for IOS & want to check when the device is rotated, when it is my code will make the video player fullscreen, but on I'm getting the following error - 'Instance member 'currentDevice' cannot be used on type 'viewController'

var currentDevice: UIDevice = UIDevice.currentDevice()
var orientation: UIDeviceOrientation = currentDevice.orientation //error here

if orientation.isLandscape {

}

if orientation.isPortrait {

}

I've tried to replace currentDevice with a multiple of things, I've also tried to put _ under it and also self.I've started working with Swift a couple of days ago, is there anyone who could point me in the right direction please?

I've found the code here.


Solution

  • I decided to force the app into landscape mode in the project settings.