قالب وردپرس درنا توس
Home / IOS Development / App crashes when trying to present the sheet of view when using SwiftUI: iOSProgramming

App crashes when trying to present the sheet of view when using SwiftUI: iOSProgramming



I try to present a view over another view in SwiftUI using .sheet (). When this is running my app, crashes without stack tracks even when run on a simulator and this error appears:

      EXC_BAD_INSTRUCTION (code = EXC_I386_INVOP, subcode = 0x0)

I've already determined that the view being presented is not the problem by trying to present Text ("Test") instead of my custom view, but I still get the same error.

  .sheet (isPresented: self. $ IsPresenting) {() -> Text i
return Text ("This is a test")
}

This is the code that sets up the view and tries to present another view when you press the green button . It looks like this on the device:

UI running in simulator

  struct WeekView: View {

@ObjectBinding was currentMealPlan = MealPlan (totalMealExchanges: 0, totalGraciesMeals: 0)
@State was isPresenting = false
was body: some show {

NavigationView {
VStack {


VStack (adjustment: leading) {
Text ("Meals that Gracies Remains 😕 / CurrentMealPlan.totalGraciesMeals)")
Text ("Remaining Meal Exchange 😕 / (CurrentMealPlan.totalMealExchanges)")
}



List{
Section (Heading: Text ("Monday")) {
HStack {


MealView (meal: "Breakfast", location: "Dormitory", color: Color.green)
.tapAction {
self.isPresenting.toggle ()

}
.ark (isPresented: self. $ isPresenting) {() -> Text i
return Text ("This is a test")
}



MealView (meal: "Lunch", location: "Gracies", color: Color.blue)
MealView (meal: "Dinner", location: "Salsarita", color: Color.yellow)



}
}

}

} .navigationBarTitle ("This Week")
.navigationBarItems (by: Button (action: {

}, label: {
Text ("Help")
}))

}

}
}





struct MealView: Show {
@State was meal: String
@State was location: String
@State was color: Color
@State private was showPopover = false

was body: some show {
ZStack {
Rectangle()
.Fill color)
VStack {
Text (meal)
.brave()
Text (location)
.lineLimit (2)
}


}
}}

Source link