0

SwiftUI を使用する私のアプリでは、アプリに分割ビューを実装したい場合、複数のアプリを使用するときに分割画面モードにしない限り、iPhone や iPad でもすべてがうまく機能します。これが ContentView() のコードです。さらに必要な場合は、お気軽にお問い合わせください。

import SwiftUI
import GoogleMobileAds

struct ContentView: View {

    @State var isAboutViewPresented = false

    var body: some View {
        NavigationView {
            DefaultView()
            NewView()
        }//.navigationViewStyle(StackNavigationViewStyle())
        // To get "full screen" on iPad -> not in a split view style
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
            .environment(\.locale, .init(identifier: "fr"))
    }
}


struct DefaultView: View {

    @State var isAboutViewPresented = false

    var body: some View {
        VStack {
            List {
                Section(header: Text("main"), footer: Text("showChartOfDesiredParameter")) {
                    NavigationLink(destination: ApertureStopChartView()) {
                        Text("apertureStopChart")
                    }
                    NavigationLink(destination: ShutterSpeedStopChartView()) {
                        Text("shutterSpeedStopChart")
                    }
                    NavigationLink(destination: ISOStopChartView()) {
                        Text("isoStopChart")
                    }
                }

                Section(header: Text("moreInfo")) {
                    NavigationLink(destination: WhatIsStopView()) {
                        Text("whatIsAStopInPhotography")
                    }
                }
            }.listStyle(GroupedListStyle())

            VStack {
                AdView().frame(width: 320, height: 50)
            }.edgesIgnoringSafeArea([.top, .leading, .trailing])

        }



            .navigationBarTitle(Text("Stop Chart"))
            .navigationBarItems(trailing:
                Button(action: {
                    self.isAboutViewPresented = true
                }) {Image(systemName: "info.circle")
                    .font(.title)
                    .foregroundColor(.blue)
                }.sheet(isPresented: $isAboutViewPresented, content: { AboutView(onDismiss: {
                    self.isAboutViewPresented = false
                })

                })
        )
    }
}


struct NewView: View {
    var body: some View {
        VStack {
            Image("StopChart-icon@1024px")
            .resizable()
                .frame(width: 400, height: 400, alignment: .center)
                .cornerRadius(23)
            HStack {
                Text("swipeToTheRight").font(.largeTitle)
                Image(systemName: "arrow.right").font(.largeTitle)
            }
        }
    }
}


struct AdView: UIViewRepresentable {

    func makeUIView(context: UIViewRepresentableContext<AdView>) -> GADBannerView {

        let banner = GADBannerView(adSize: kGADAdSizeBanner)

        banner.adUnitID = "ca-app-pub-3940256099942544/2934735716"
        banner.rootViewController = UIApplication.shared.windows.first?.rootViewController
        banner.load(GADRequest())
        return banner
    }

    func updateUIView(_ uiView: GADBannerView, context: UIViewRepresentableContext<AdView>) {

    }
}

バグを示す GIF

ご協力いただきありがとうございます。

4

1 に答える 1