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

    OpenAI’s GPT-5.5 in Microsoft Foundry: Frontier intelligence on an enterprise ready platform

    April 27, 2026

    Meta’s compute grab continues with agreement to deploy tens of millions of AWS Graviton cores

    April 27, 2026

    John Ternus could borrow from Microsoft’s playbook to reinvigorate Apple

    April 27, 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

    Delphi + PAServer: How to correctly export iOS app with Notification Service Extension (appex) – missing provisioningProfiles in exportOptions.plist

    April 27, 2026

    ios – Apply shadow only outside of a SwifUI transparent button?

    April 26, 2026

    ios – How to add pictures after keynote update with iPadOS 26.3.1?

    April 25, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    OpenAI’s GPT-5.5 in Microsoft Foundry: Frontier intelligence on an enterprise ready platform

    April 27, 2026

    Meta’s compute grab continues with agreement to deploy tens of millions of AWS Graviton cores

    April 27, 2026

    John Ternus could borrow from Microsoft’s playbook to reinvigorate Apple

    April 27, 2026

    Delphi + PAServer: How to correctly export iOS app with Notification Service Extension (appex) – missing provisioningProfiles in exportOptions.plist

    April 27, 2026
    Timer Code
    15 Second Timer for Articles
    20
    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!

    OpenAI’s GPT-5.5 in Microsoft Foundry: Frontier intelligence on an enterprise ready platform

    April 27, 2026

    Meta’s compute grab continues with agreement to deploy tens of millions of AWS Graviton cores

    April 27, 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.