Wednesday, 21 August 2019

Content displayed on a connected screen is not showed in full screen in Swift

When testing my app in a real device connected to a tv or monitor by hdmi cable, the content that is showed in the connected screen is not showed in full screen.

In a real device with a real connected screen: enter image description here

I have tested my app in the iOS Simulator with the simulated connected screen and everything works great.

In the iOS Simulator: enter image description here

I have tested my app in different kinds of screens and the content in the connected screen is never showed in full screen when using real devices.

I have also tested this example having the same results.

This is part of the code:

if UIScreen.screens.count > 1 {
    let secondScreen = UIScreen.screens[1]
    secondWindow = UIWindow(frame: secondScreen.bounds)
    secondWindow.rootViewController = UIViewController()
    secondWindow.screen = secondScreen

    let secondScreenView = UIView(frame: secondWindow.frame)
    secondWindow.addSubview(secondScreenView)
    secondWindow.isHidden = false

    secondScreenView.backgroundColor = .purple

    let imageView = UIImageView(frame: secondScreenView.bounds)
    imageView.image = UIImage(data: recursoTipoRecurso.recurso.contenido as Data)
    imageView.contentMode = .scaleToFill

    secondScreenView.addSubview(imageView)
}

As showed in the previous images there is a space between the monitor screen border and the content I set.

What am I doing wrong?



from Content displayed on a connected screen is not showed in full screen in Swift

No comments:

Post a Comment