I have declared an array as a State var
@State var proba : [Int] = [10, 40, 40, 10]
The array is updated in onAppear :
.onAppear {
proba = arrayOfTuples.map { (proba, _) in proba }
print("proba", proba)
}
The array is used for TextFields:
ForEach(0..<proba.count, id: \.self) { index in
TextField("N", value: $proba[index], format: .number)
.frame(width: 40)
.onChange(of: proba_kWh[index], perform: {[oldValue = proba_kWh[index]]
newValue in
print("proba onChange", index, oldValue, proba[index], newValue)
})
When View appears, I get some onChange (as initial values did change)
proba [10, 20, 60, 10] // onAppear changes 2 values: 1 and 2
proba onChange 2 40 60 60 // index 2 is changed before 1
proba onChange 1 40 20 20
I know that order of execution is not guaranteed, but in this specific case, I did thought it would be in the order of the array reading…
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have an app that runs eitheir as MacOS or iPadOS.
After a few changes to adapt to API differences (PasteBoard notably), app runs OK on both.
But the layout of views is messy when running on iPad.
Reason seems to be that Text are not using the same default font size, or that the same system font size does not use the same space. Same issue when using segmented picker for instance.
Configuration:
Xcode 14.2
MacOS 12.6.6
Simulator: iPad Pro (12.9") - iOS 16.2
Is it a correct analysis ?
Is there a simple workaround, to avoid the need to redesign all views for iPadOS ?
If I run the exact same code on MacOS 12.7 (Xcode 14.2) and MacOS 15.0.1 (Xcode 15.0.1).
In a scrollView, I display lines (lineDivider) and then a LazyVgrid, applying some offset:
ScrollView(.vertical) {
ForEach(1...50, id: \.self) { index in
LabelledDivider(label: "\(index)", color: .gray.opacity(0.1))
.offset(y: CGFloat(65*index - 50)
}
LazyVGrid(columns: gridItemLayout, spacing: 33 ) {
ForEach ($allItems.theItems) { $item in
ItemView(item: item)
}
}
.offset(y: 40)
}
In Xcode 14.2, I get the first layout and in Xcode 15.0 the second on right:
The divider line is at the same position, but the view in grid is not.
If I change
.offset(y: 40)
to
.offset(y: 60)
I get the same layout.
So my questions:
did anyone observe similar change ?
is it due to Xcode, to MacOS ?
Is it documented somewhere ?
This app allows to take photos.
It works OK, but since recently I get the following error message:
ERROR: PHOTO not found in table CameraUI-SpatialVideo of bundle CFBundle 0x283e96220 </System/Library/PrivateFrameworks/CameraUI.framework> (not loaded)
What is this spatial video ? I'm just using still images, not using CameraUI.framework.