iPadOS 13.4 beta 上の Swift Playgrounds で NavigationView
5480 ワード
iPadOS13.4ベータ版でDoubleColumnNavigationViewStyleなNavigationviewが少しまともに動くようになったので、そのサンプルコードをメモ。
import SwiftUI
struct ContentView: View {
static let items = Array(1...30)
@State var selected: Int? = Self.items.first
var body: some View {
NavigationView {
List(Self.items, id: \.self) { i in
NavigationLink(destination: Secondary(item: i), tag: i, selection: self.$selected) {
Text("Item \(i)")
}
}
.navigationBarTitle("Primary")
}
}
}
struct Secondary: View {
var item: Int
var body: some View {
Text("Item \(item)")
.font(.largeTitle)
.navigationBarTitle("Secondary")
}
}
import PlaygroundSupport
let controller = UIHostingController(rootView: ContentView())
PlaygroundPage.current.setLiveView(controller)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
(controller.children.first as? UISplitViewController)?.preferredDisplayMode = .allVisible
}
asyncAfterを使った手抜きコードだけど参考にはなるかと。
Author And Source
この問題について(iPadOS 13.4 beta 上の Swift Playgrounds で NavigationView), 我々は、より多くの情報をここで見つけました https://qiita.com/tom-u/items/2cdae15c7a101dfaa279著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .