SwiftUI Present Alert with Input Field?

泪湿孤枕 提交于 2019-11-28 12:16:29

问题


In SwiftUI I'm trying to make an alert message with input, and then get the value from the input. I've found many good tutorials how to make the Alert View in SwiftUI, but dont found how to add TextField() in Alert. This alert will update Categories table on Server, i will call a put request with this alert.

@State var isInsertAlertVisible = false
// state var is define in ContentView
// Button is define in body
Button(action: {
       self.isInsertAlertVisible = true
       }
       ,
       label: {
       Text("Create")
          .multilineTextAlignment(.center)
          .foregroundColor(Color.white)
})
.presentation($isInsertAlertVisible) {
    Alert(title: Text("Insert"), message:
        Text("Insert Categories"), dismissButton: .default(Text("OK!")){
            print("Got it")
    })

}
.padding(.all)
.background(Color.blue)

来源:https://stackoverflow.com/questions/57148220/swiftui-present-alert-with-input-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!