Fullscreen

I am learning to code on my iPad using Swift Playgrounds. I like to have my programs run on a full screen. I will paste below a simple example of my code.

When I run my code on a blank page it appears on a split screen with a border around it. Of course I can slide the boundary over and get rid of the split screen.

When I run it on the shapes page I get a full screen ( with the split screen). Is there a simple command to make the code run on a fullscreen on the blank page?

For example in another well known coding app the command is:
viewer.mode=(FULLSCREEN)


Import SwiftUI
import PlaygroundSupport
struct ContentView: View {
    
    @State private var slide: Double = 0
    
    var body: some View {
        VStack {
            
            Slider(value: $slide, in: -100...100, step: 0.1)
            
            Text("You slid: \(slide)")
            
        }
    }
}

PlaygroundPage.current.setLiveView(ContentView())

You can set the property wantsFullScreenLiveView to achieve this in Swift Playgrounds. I.e.

PlaygroundPage.current.wantsFullScreenLiveView = true

Hi and thanks for the reply.
If I put PlaygroundPage.current.wantsFullScreenLiveView = true
at the end of my code and remove PlaygroundPage.current.setLiveView(ContentView())
I get a full screen like I want but there is nothing happening on it.
If include both statements with PlaygroundPage.current.setLiveView(ContentView()) second my code works but not (quite) in full screen.
So where should I put these statements.

Hi, you’ll need both of the PlaygroundPage lines at the end of the main page. For me, the order doesn’t make any difference.

However, you’ll still see Swift Playground controls at the top and bottom of the screen, such as the buttons to access the console, and stop code execution.

Hi and thanks.
That works but the page has a border around it as in the photo, which is close enough. When I run the code on the shapes page it is on a full screen with no borders around it.

Also there is no enable results switch on the shapes page. This switch being on causes some of the controls to not function. It keeps coming back on.
I am thinking I will do my coding on the shapes page.

Cheers
Ken

These questions about Apple-specific frameworks, software, and devices should really be asked elsewhere, like the Apple Developer forums. These forums are for the open-source Swift language and supporting infrastructure. SwiftUI, Combine, iPad playgrounds are not part of that infrastructure. These forums are not supposed to be about Apple development and programming.

Ok I will try and find a forum for SwiftUI. Thanks for your help up to this point.

Terms of Service

Privacy Policy

Cookie Policy