Questions tagged [swiftui-alert]

9 questions
21
votes
4 answers

Issue with SwiftUI displaying Alert – Will not display alert box

I have the following code: @State private var signoutAlert = false var body: some View { Button(action: { self.signoutAlert = true print("signout button clicked") }) { Text("Sign…
Learn2Code
  • 1,974
  • 5
  • 24
  • 46
6
votes
2 answers

SwiftUI - show Alert from Button inside of ToolbarItem

I want to do something similar to the code below, where it shows an alert when a user taps a navigation bar item button. However the code below doesn't work, the alerts do not display. I can't add the alert modifiers to the NavigationView because my…
marchinram
  • 5,698
  • 5
  • 47
  • 59
4
votes
1 answer

Create an Alert with just one action button

I want an Alert with one button that runs some code. I do not want there to be a cancel button. I've only seen a way to have two buttons, with primaryButton and secondaryButton. Is there a way to do something like this?
Evan93
  • 155
  • 11
2
votes
2 answers

How to present an Alert in SwiftUI with no buttons

I have a situation where I would like to recreate previous UIKit logic by displaying an Alert during a long running operation that the user cannot interact with. Previously in UIKit, it would be this simple: import UIKit class ViewController:…
CodeBender
  • 35,668
  • 12
  • 125
  • 132
1
vote
1 answer

SwiftUI: Alert that does not close when clicking on button

I'm new to SwiftUI and I'm trying to display an alert that does only close on some conditions but not on every click on its buttons. Is that possible or does it strike against the concept of alerts? My code is like this: .alert("title", isPresented:…
1
vote
1 answer

sheet can not be dismissed after an alert is displayed

I’m trying to show alerts in a sheet in SwiftUI. I have Cancel and Save buttons on the sheet and both of them are dismissed after the action is done.If there is an error on saving, an alert is pop upped. However, the sheet can not be dismissed…
Feyza
  • 11
  • 1
0
votes
1 answer

SwiftUI alert is not displaying when navigating to screen second time

I have one application in which i am making api call, in this application i want to display error if API does not return the response. When i navigate first time to the screen, it displays alert message, but when i go back to previous screen and…
iosdev1111
  • 1,048
  • 1
  • 13
  • 32
0
votes
1 answer

Swift - Thread 1: EXC_BAD_INSTRUCTION when deleting object from Coredata

I'm trying to delete an object from Coredata, and I sometimes get the error Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0), and my app crashes, when I delete an object. The console also spits out tons of information but this seem…
Cameron Delong
  • 454
  • 1
  • 6
  • 12
-1
votes
1 answer

presenting a confirm alert after an alert with swiftui not working

i'm trying to show a confirmation alert after you press the "Confirm" button on the first alert. Idea: You press a button and an alert pops up that asks you to cancel or confirm the action. When you press cancel, the alert gets dismissed and when…
Merdis
  • 37
  • 4