Thsi piece of code seems to be the issue. I asked the two users on whom the app is crashing, to turn of "instant feedback" feature off and the app is not crashing.
So it is the scrollTo option which is the issue. Can something be fixed in this so that it does not crash in 16.x OS?
if oldValue == false && newValue == true {
withAnimation {
proxy.scrollTo("ExplanationLabel" , anchor: .bottomTrailing)
}
}
}
Post
Replies
Boosts
Views
Activity
And here is the code
struct QuizContentView: View {
@Binding var currentQuestionNumber: Int
@Binding var expVisibility: Bool
@ObservedObject var dataManager: DataManager = DataManager.shared
var onAnswerSelectedClosure: ((Int) -> Void)?
var body: some View {
if dataManager.currentQuiz.questionsForCurrentTest.count > 0 {
ZoomableImageView(graphic:dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].content.graphic)
ScrollViewReader { proxy in
List{
if (AppSettings.isTestingPhaseActive()){
Text(dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].id)
}
EmptyView().id("scrollToPos")
QuestionTextView(text:dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].instruction, isInstruction: true)
.italicText()
.listRowInsets(EdgeInsets()) // Removes the default padding
.listRowBackground(Colors.questionBackground)
QuestionTextView(text:dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].processedQuestionText)
.listRowInsets(EdgeInsets()) // Removes the default padding
.listRowBackground(Colors.questionBackground)
if (AppSettings.isMultipleAnswerSelectionAllowed()){
PromptView(text: dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].prompt)
.listRowInsets(EdgeInsets()) // Removes the default padding
.listRowBackground(Colors.promptBackground)
}
ForEach(dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].answers.indices, id:\.self) { index in
SingleAnswerView(text: dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].answers[index].content.text,
graphic: dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].answers[index].content.graphic,
fillColor: Colors.getAnswerColor(question: dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber],answerIndex: index,isReviewMode:dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].explanation.visibility)
){
if (dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].explanation.visibility == false){
if let closure = onAnswerSelectedClosure {
closure(index)
}
}
}
.id(index)
}//for each
if(dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].explanation.visibility ) {
ExplanationView(text:dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].explanation.content.text,
graphic:dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].explanation.content.graphic, reference: dataManager.currentQuiz.questionsForCurrentTest[currentQuestionNumber].reference, fillColor: Colors.explanationBackground)
}
}//list
.listStyle(.plain) //to make entire screen white
//MARK:scroll issue fix below with two .onChange methods, note expVisibility and explanation.visibility must be separate for reviewing
.onChange(of: expVisibility) { [oldValue = expVisibility] newValue in
if oldValue == false && newValue == true {
withAnimation {
proxy.scrollTo("ExplanationLabel" , anchor: .bottomTrailing)
}
}
}
.onChange(of: currentQuestionNumber) { _ in
withAnimation {
proxy.scrollTo("scrollToPos", anchor: .topLeading) //first answer
}
}
}//scrollview reader of list
}
}
}
Where can I see that? In "trends" I can only see by the metric "device", not "OS".
Thank you. I myself am unable to reproduce this error. I have tried running it on simulators with 16.x but I do not get this exception. Two users who have reported this issue have following devices and OSs. The app is crashing during taking a quiz with question and answers (SwiftUI List). There is no direct use of UICollectionView in my code, although scrollToPosition is used to scroll when explanation for the answer appears.
Model: iPhone12,1. OS: 16.2
Model: iPhone15,3. OS: 16.3.1
Main exception is : VM - pmap_enter retried due to resource shortage
Am on Xcode 15.0
**DOES NOT WORK IN FOLLOWING
**
Simulators: Model iPad Pro (12.9")iOS 17.0 both 3rd gen and 6th gen
Devices: iPad Model MQDx2LL/A 10.5" 17.0
It is easily reproducible if you start from top to bottom and then go bottom to top in list selection, then it starts skipping calling onAppear randomly.
**WORKS PERFECTLY WELL IN
**
Simulator: Model iPad Pro 11" 1st gen 15.0
I am unable to find iOS16.x simulators in my Xcode, all show up only with 15.0. or 17.0
I was just trying to force UI redraw with .id(UUID()) but with it or without it , it behaves the same erratic way.
thank you so much Claude31. You saved many days of mine. My case was this: when I was having destination as simple Text it was working without $ sign everywhere. But when I set the destination to a custom view which has a binding variable, I needed $ as mentioned by you.
NavigationSplitView {
List {
ForEach($topics, id: \.self) { $topic in
NavigationLink(destination:BeginQuizView(topic:$topic)) {
//NavigationLink(destination:Text(topic.title)) {
Yes .m4v, files are not showing/playing in iOS 14 either in device or simulator! Please fix asap!!, .mp4,.MOV are at least showing, but not playing too.
This is resolved. I had a web view being initialized to CGRectNull