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

    ios – Why does my page scroll up when I tap on a button?

    January 25, 2026

    Konni hackers target blockchain engineers with AI-built malware

    January 24, 2026

    The Human Behind the Door – O’Reilly

    January 24, 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 – SwiftUI view state resetting after alert is shown
    iOS Development

    ios – SwiftUI view state resetting after alert is shown

    big tee tech hubBy big tee tech hubJanuary 22, 2026022 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – SwiftUI view state resetting after alert is shown
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    Seeing an issue in iOS 26.2 iPhone 17 simulator (haven’t been able to reproduce on device), where a view’s state is reset after an alert is shown.

    In this example the first LibraryView has the issue when alert is shown, the second LibraryView maintains state as expected.

    struct ContentView: View {
    
        var body: some View {
            NavigationStack {
                List {
                    VStack {
                        LibraryView(title: "Show view (Loss of state)")
                    }
                    
                    LibraryView(title: "Show view (Works as expected)")
                }
            }
        }
    }
    
    /// This view is from a package dependency and wants to control the presentation of the sheet internally
    public struct LibraryView: View {
        @State private var isPresented: Bool = false
        let title: String
        
        public init(title: String) {
            self.title = title
        }
        
        public var body: some View {
            Button(self.title) {
                self.isPresented = true
            }
            .sheet(isPresented: self.$isPresented) {
                ViewWithAlert()
            }
        }
    }
    
    private struct ViewWithAlert: View {
        @State private var isPresented: Bool = false
        @State private var presentedCount = 0
        
        var body: some View {
            Button("Show Alert, count: \(presentedCount)") {
                isPresented = true
                presentedCount += 1
            }
            .alert("Hello", isPresented: self.$isPresented) {
                Button("OK") { }
            }
        }
    }
    
    
    

    Any ideas?

    The issue can be corrected by moving the .sheet to a higher level within the layout (i.e. on the NavigationStack). However, the library wants to control that presentation and not require the integration to present the sheet.



    Source link

    alert iOS resetting shown State SwiftUI view
    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 – Why does my page scroll up when I tap on a button?

    January 25, 2026

    swift – iOS suspends app after BLE discovery even though I start Always-authorized location udpates

    January 24, 2026

    ios – ASAuthorizationControllerDelegate always returns .canceled for Face ID passcode fallback and failed attempts

    January 23, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    ios – Why does my page scroll up when I tap on a button?

    January 25, 2026

    Konni hackers target blockchain engineers with AI-built malware

    January 24, 2026

    The Human Behind the Door – O’Reilly

    January 24, 2026

    Nanomaterials Transformed by Engineering Shape, Not Chemistry

    January 24, 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!

    ios – Why does my page scroll up when I tap on a button?

    January 25, 2026

    Konni hackers target blockchain engineers with AI-built malware

    January 24, 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.