Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Your Signal account is safe

    March 12, 2026

    3 Questions: On the future of AI and the mathematical and physical sciences | MIT News

    March 12, 2026

    Iran war: US responsible for strike on Iranian school, investigation finds

    March 12, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – How to define confirmationDialog with Binding Item instead of isPresented one?
    iOS Development

    ios – How to define confirmationDialog with Binding Item instead of isPresented one?

    big tee tech hubBy big tee tech hubAugust 28, 2025052 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – How to define confirmationDialog with Binding Item instead of isPresented one?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    This is what I have, to present confirmationDialog on tap:

    extension View {
        func confirmDeletion(isPresented: Binding, title: String? = nil, action: @escaping ()-> Void) -> some View {
            confirmationDialog("", isPresented: isPresented) {
                Button("delete", role: .destructive) { action() }
            } message: {
                Text(title)
            }
        }
    }
    

    And it works perfectly, but now I need to define and call it base on selected Item from the list, not just by toggle isPresented, so I simply defined it like this:

    extension View {
        // here is previous declaration
        func confirmDeletion(item: Binding, title: String? = nil, action: @escaping (Item)-> Void) -> some View {
            let binding = Binding {
                item.wrappedValue != nil
            } set: { _ in }
    
            return confirmDeletion(isPresented: binding, title: title) { // call the previous declaration with overriden action
                if let item = item.wrappedValue {
                    action(item)
                }
            }
        }
    }
    

    But the issue is that it is displayed only once. When I tap the same PlanElementView in a row, it doesnt present dialog second time. Why? When I tap different PlanElementView it works.

    In code I use it like this:

    @State var selectedPlanForDeletion: Plan?
    
    var body: some View {
        VStack {
            ForEach(plans) { plan in
                PlanElementView(plan: plan)
                    .onTapGesture {
                        selectedPlanForDeletion = plan
                    }
            }
        }
        .confirmDeletion(
            item: $selectedPlanForDeletion,
            title: "newTitle"
        ) { plan in
            print(plan)
        }
    }
    



    Source link

    Binding confirmationDialog define iOS isPresented Item
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – SwiftUI iOS26+ Transition or Animation after TextField value entered

    March 12, 2026

    uikit – Why the title doesn’t follow the navigation inline state in iOS 26

    March 11, 2026

    ios – OS emoji keyboard causes UI freeze in chat TextField Flutter

    March 10, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Your Signal account is safe

    March 12, 2026

    3 Questions: On the future of AI and the mathematical and physical sciences | MIT News

    March 12, 2026

    Iran war: US responsible for strike on Iranian school, investigation finds

    March 12, 2026

    MaxLiveProtect: eBPF-Powered Network Infrastructure Security

    March 12, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Your Signal account is safe

    March 12, 2026

    3 Questions: On the future of AI and the mathematical and physical sciences | MIT News

    March 12, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.