各位大大好,小菜雞在此首次發文求救
自學swiftui時遇到一些問題
因為.actionSheet之後會被棄用
apple建議使用.confirmationDialog
結果感覺遇到問題了
下面這段的Delete按鈕點擊選單會先消失再出現在消失,希望選單消失就別再出現了
.confirmationDialog("What do you want to do", isPresented: self.$showActionSheet, titleVisibility: .visible) {
Button("Make as Favorite"){
if let selectedRestaurant = selectedRestaurant {
self.setFavorite(item: selectedRestaurant)
}
}
Button("Delete",role: .destructive){
if let selectedRestaurant = selectedRestaurant {
self.delete(item: selectedRestaurant)
}
}
Button("Cancel", role: .cancel) {
}
}
更換成下面這段顯示就是正常的
.actionSheet(isPresented: self.$showActionSheet) {
ActionSheet(title: Text("What do you want to do"), message: nil, buttons: [
.default(Text("Mark as Favorite"), action: {
if let selectedRestaurant = self.selectedRestaurant {
self.setFavorite(item: selectedRestaurant)
}
}),
.destructive(Text("Delete"), action: {
if let selectedRestaurant = self.selectedRestaurant {
self.delete(item: selectedRestaurant)
}
}),
.cancel()
])
}
滿好奇這是bug還是我的用法錯誤了
有沒有大大有相關經驗可以分享的
非常感激> <