首页 > 解决方案 > 嵌套按钮没有响应

问题描述

我在 hstack 中并排有一个导航链接和一个按钮,但点击时两者都没有响应。

navigationbaritems 按钮按预期工作。

NavigationView {
    ZStack {
           "Buttons here works fine"
       VStack{
           HStack(alignment: .center) {
               NavigationLink(destination: ProfileView()) {
                   Text("anonymous")
                       .font(.caption)
                       .fontWeight(.bold)
                   }

                   Spacer()

                   Button(action: { self.cardOptions.toggle() }) {
                       Image(systemName: "ellipsis")
                           .frame(width: 32, height: 32, alignment: .center)
                           .font(Font.title.weight(.black))
                               .foregroundColor(Color("costumLightGrey"))
                    }.alert(isPresented:$cardOptions) {
                        Alert(title: Text("Alert"), message: Text("Message"), primaryButton: .destructive(Text("Delete")) {
                                print("Did tap")
                    }, secondaryButton: .cancel())
                }
           }
       }
    }
}

标签: swiftswiftui

解决方案


推荐阅读