watchOS 多个工具栏项目

发布于 2025-01-20 15:01:00 字数 450 浏览 2 评论 0原文

我的目标是在我的WatchOS应用程序中将2个按钮作为工具栏项目,但是即使我将其分组为工具键或单独放置多个工具栏,也只有一个显示。知道这里有什么问题吗?

.toolbar {
    ToolbarItem {
        Button("1") {
        }
    }
    ToolbarItem {
        Button("2") {
        }
    }
}

或者

.toolbar {
    ToolbarGroup {
        Button("1") {
        }
        Button("2") {
        }
    }
}

my goal is to have 2 buttons as a toolbar item in my WatchOS app, but even if I group them in a toolbargroup or place multiple toolbarItems on their own, there is only one that is shown. Any idea what is wrong here ?

.toolbar {
    ToolbarItem {
        Button("1") {
        }
    }
    ToolbarItem {
        Button("2") {
        }
    }
}

or

.toolbar {
    ToolbarGroup {
        Button("1") {
        }
        Button("2") {
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初与友歌 2025-01-27 15:01:00

好的,找到了。将它们放在堆栈(V或H)工作中

.toolbar {
    ToolbarGroup {
        VStack {
            Button("1") {
            }
            Button("2") {
            }
        } 
    }
}

Ok, found it. Placing them in a Stack (V or H) works

.toolbar {
    ToolbarGroup {
        VStack {
            Button("1") {
            }
            Button("2") {
            }
        } 
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文