我正在开发 SwiftUI 视图。当在 TabView 中使用 NavigationView 时,应用程序将按预期工作。
struct ContentView: View {
var body: some View {
TabView {
NavigationView {
Text("A")
.navigationBarTitle("Nav A")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
NavigationView {
Text("B")
.navigationBarTitle("Nav B")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
//.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) // this line breaks the view
}
}
Run Code Online (Sandbox Code Playgroud)
一旦我取消注释,.tabViewStyle(...)视图就不会按预期工作。有什么想法吗?文字不再可见。导航似乎也不正确。
当尝试在我的 Ubuntu 机器上启动时,solana-test-validator我收到以下错误:
Error: failed to start validator: Failed to create ledger at test-ledger: blockstore error
Run Code Online (Sandbox Code Playgroud)
详细查看错误日志时,我注意到以下问题:
[0m[38;5;8m[[0m2021-12-11T10:29:28.942979023Z [0m[1m[31mERROR[0m solana_ledger::blockstore[0m[38;5;8m][0m tar stderr: /bin/sh: 1: bzip2: not found
Run Code Online (Sandbox Code Playgroud) 我使用 Vite 创建了一个 React 应用程序并安装了Mantine v6.0.0. 当我调用以下函数打开 Mantine 模态时,视图变暗,但模态不可见。
const openModal = () => modals.openConfirmModal({
title: 'Please confirm your action',
children: (
<Text size="sm">
This action is so important that you are required to confirm it with a modal. Please click
one of these buttons to proceed.
</Text>
),
labels: { confirm: 'Confirm', cancel: 'Cancel' },
onCancel: () => console.log('Cancel'),
onConfirm: () => console.log('Confirmed'),
});
Run Code Online (Sandbox Code Playgroud) 我正在使用 SwiftUI,并希望在使用 ColorPicker 选择颜色后立即将其保存到 UserDefaults 中。做这个的最好方式是什么?
struct CustomizeView: View {
@State private var color: Color = Color.green
var body: some View {
ColorPicker("Select a color!", selection: $color, supportsOpacity: false)
}.onAppear {
guard let defaults = UserDefaults(suiteName: "...") else { return }
color = Color(rgb: defaults.integer(forKey: "color"))
}
}
// where do I call the saveColors() function?
func saveColors() {
guard let defaults = UserDefaults(suiteName: "...") else { return }
defaults.set(color.rgb, forKey: "colorCancel")
defaults.synchronize()
}
}
Run Code Online (Sandbox Code Playgroud)
(颜色的 rgb 初始值设定项是自定义的,不应该相关。)