Post

Replies

Boosts

Views

Activity

Sheet presented is blank in iOS 14.x (@State variables not setting)
Using the below code works fine in iOS 13.x. Beginning in iOS 14.0 the code fails. Somehow neither of the @State variables are getting set to their new values on the first button push. If you continue to select the same button after dismissing the sheet (swiping down) the same behavior happens. If after dismissing the sheet a different button is selected the state variables now get set and the proper sheet presents forever after. I have submitted feedback to apple but have yet to hear how to fix this. Whats even more strange is that the @State variable to present the sheet is not registering being set to true yet the .sheet(present: content:) still fires and presents the sheet. I have an App ready to ship but this is preventing me from submitting because its a bug I can't repair nor can I find a workaround. This code works in iOS 13.x and in 14.0 once two different buttons have been selected. Any work around help would be appreciated. struct ContentView: View {     enum ActiveSheet: String {         case one, two, three, none     }     @State var activeSheet: ActiveSheet = .none     @State var presentSheet = false     var body: some View {         VStack {             Button("Sheet 1", action: {                 self.activeSheet = .one                 self.presentSheet = true             })             .padding()             Button("Sheet 2", action: {                 self.activeSheet = .two                 self.presentSheet = true             })             .padding()             Button("Sheet 3", action: {                 self.activeSheet = .three                 self.presentSheet = true             })             .padding()         }         .sheet(isPresented: self.$presentSheet, content: {             if activeSheet == . one {                 VStack {                     Text("Sheet 1")                     Text("activeSheet : \(self.activeSheet.rawValue)")                     Text("presentSheet : \(self.presentSheet == true ? "true" : "false")")                 }             } else if activeSheet == .two {                 VStack {                     Text("Sheet 2")                     Text("activeSheet : \(self.activeSheet.rawValue)")                     Text("presentSheet : \(self.presentSheet == true ? "true" : "false")")                 }             } else if activeSheet == .three {                 VStack {                     Text("Sheet 3")                     Text("activeSheet : \(self.activeSheet.rawValue)")                     Text("presentSheet : \(self.presentSheet == true ? "true" : "false")")                 }             } else {                 VStack {                     Text("Blank Sheet")                     Text("activeSheet : \(self.activeSheet.rawValue)")                     Text("presentSheet : \(self.presentSheet == true ? "true" : "false")")                 }             }         })     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
4
0
2.3k
Sep ’20
UILabel Crash with Attributed Text
In Xcode version 10.0 and swift 4.2 my app crashes when setting the content of UILabel.attributedText and accessing any of UILabels variables.For examplelet label = UILabel()label.attrubitedText = NSAttirbutedText("String")label.sizeToFit() //this will crash the Applabel. (any method or variable) will crash the appIf you don't set the attributed text variable then any follow on calls to label work fine.What needs to be done to stop the crash?Help
7
0
5.2k
Oct ’18