First the model:
import SwiftData
//Model one: type of contract, i.e. Firm Fixed Price, etc
@Model
final class TypeOfContract {
var contracts: [Contract]
@Attribute(.unique) var typeName: String
@Attribute(.unique) var typeCode: String
var typeDescription: String
init(contracts: [Contract], typeName: String = "", typeCode: String = "", typeDescription: String = "") {
self.contracts = contracts
self.typeName = typeName
self.typeCode = typeCode
self.typeDescription = typeDescription
}
}
//Model two: the Contract
@Model
final class Contract {
var contractType: TypeOfContract?
var costReports: [CostReport]
@Attribute(.unique) var contractNumber: String
@Attribute(.unique) var contractName: String
var startDate: Date
var endDate: Date
var contractValue: Decimal
var contractCompany: String
var contractContact: String
var contactEmail: String
var contactPhone: String
var contractNotes: String
init(contractType: TypeOfContract?, costReports: [CostReport], contractNumber: String = "", contractName: String = "", startDate: Date = .now, endDate: Date = .now, contractValue: Decimal = 0.00, contractCompany: String = "", contractContact: String = "", contactEmail: String = "", contactPhone: String = "", contractNotes: String = "") {
self.contractType = contractType
self.costReports = costReports
self.contractNumber = contractNumber
self.contractName = contractName
self.startDate = startDate
self.endDate = endDate
self.contractValue = contractValue
self.contractCompany = contractCompany
self.contractContact = contractContact
self.contactEmail = contactEmail
self.contactPhone = contactPhone
self.contractNotes = contractNotes
}
}
//Model Three: The Cost Reports
@Model
final class CostReport {
var contract: Contract?
var periodStartDate: Date
var periodEndDate: Date
var bCWP: Double //Budgeted Cost Work Performed
var aCWP: Double //Actual Cost Work Performed
var bCWS: Double //Budgeted Cost Work Scheduled
//Calculated fields
init(contract: Contract?, periodStartDate: Date = .now, periodEndDate: Date = .now, bCWP: Double = 0.0, aCWP: Double = 0.0, bCWS: Double = 0.0) {
self.contract = contract
self.periodStartDate = periodStartDate
self.periodEndDate = periodEndDate
self.bCWP = bCWP
self.aCWP = aCWP
self.bCWS = bCWS
}
}
Now the code for the Picker
```import SwiftUI
import SwiftData
struct EnterNewContract: View {
@Environment(\.modelContext) var modelContext
@Query(sort: \TypeOfContract.typeName) private var typeOfContracts: [TypeOfContract]
@Query private var contracts: [Contract]
@State private var costReports: [CostReport] = []
@State private var contractType: [TypeOfContract]?
@State private var contractNumber: String = ""
@State private var contractName: String = ""
@State private var startDate: Date = Date()
@State private var endDate: Date = Date()
@State private var contractValue: Decimal = 0
@State private var contractCompany: String = ""
@State private var contractContact: String = ""
@State private var contactEmail: String = ""
@State private var contactPhone: String = ""
@State private var contractNotes: String = ""
var body: some View {
Form {
VStack {
Section(header: Text("Enter New Contract")
.foregroundStyle(.green)
.font(.headline)){
Picker("Select a type of contract", selection: $contractType) {Text("Select type").tag(nil as TypeOfContract?)
ForEach(typeOfContracts, id: \.self) { typeOfContracts in
Text(typeOfContracts.typeName) .tag(typeOfContracts as TypeOfContract?)
}
}
TextField("Contract Number", text: $contractNumber)
.frame(width: 800, height: 40)
TextField("Contract Name", text: $contractName)
.frame(width: 800, height: 40)
DatePicker("Contract Start Date", selection: $startDate, displayedComponents: [.date])
DatePicker("Contract End Date", selection: $endDate, displayedComponents: [.date])
}
}
}
}
}
The code works, for the most part. The selection I make from the list does not appear. Instead there is just a shaded empty box . Also, I need to select my selection choice twice before the check mark to appear. To see the choices and my selection I must click on the empty shaded box.
What did I do wrong
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
When using a TextField with axis to set to .vertical on iOS, it sets a bound selection parameter to an erroneous value. Whilst on MacOS it performs as expected.
Take the following code:
import SwiftUI
@main
struct SelectionTestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
@FocusState private var isFocused: Bool
@State private var text = ""
@State private var textSelection: TextSelection? = nil
var body: some View {
TextField("Label", text: $text, selection: $textSelection, axis: .vertical)
.onChange(of: textSelection, initial: true) {
if let textSelection {
print("textSelection = \(textSelection)")
} else {
print("textSelection = nil")
}
}
.focused($isFocused)
.task {
isFocused = true
}
}
}
Running this on MacOS target gives the following on the console:
textSelection = nil
textSelection = TextSelection(indices: SwiftUI.TextSelection.Indices.selection(Range(0[any]..<0[any])), affinity: SwiftUI.TextSelectionAffinity.downstream)
Running the code on iOS gives:
textSelection = TextSelection(indices: SwiftUI.TextSelection.Indices.selection(Range(1[any]..<1[any])), affinity: SwiftUI.TextSelectionAffinity.upstream)
textSelection = TextSelection(indices: SwiftUI.TextSelection.Indices.selection(Range(1[any]..<1[any])), affinity: SwiftUI.TextSelectionAffinity.upstream)
Note here the range is 1..<1 - which is incorrect.
Also of side interest this behaviour changes if you remove the axis parameter:
textSelection = nil
Am I missing something, or is this a bug?
I’m seeing unexpected scroll behavior when embedding a LazyVStack with dynamically sized views inside a ScrollView.
Everything works fine when the item height is fixed (e.g. colored squares), but when I switch to text views with variable height, the scroll position jumps and glitches—especially when the keyboard appears or disappears. This only happens on iOS 26, it works fine on iOS 18.
Working version
struct Model: Identifiable {
let id = UUID()
}
struct ModernScrollView: View {
@State private var models: [Model] = []
@State private var scrollPositionID: String?
@State private var text: String = ""
@FocusState private var isFocused
// MARK: - View
var body: some View {
scrollView
.safeAreaInset(edge: .bottom) { controls }
.task { reset() }
}
// MARK: - Subviews
private var scrollView: some View {
ScrollView {
LazyVStack {
ForEach(models) { model in
SquareView(color: Color(from: model.id))
.id(model.id.uuidString)
}
}
.scrollTargetLayout()
}
.scrollPosition(id: $scrollPositionID)
.scrollDismissesKeyboard(.interactively)
.defaultScrollAnchor(.bottom)
.onTapGesture {
isFocused = false
}
}
private var controls: some View {
VStack {
HStack {
Button("Add to top") {
models.insert(contentsOf: makeModels(3), at: 0)
}
Button("Add to bottom") {
models.append(contentsOf: makeModels(3))
}
Button("Reset") {
reset()
}
}
HStack {
Button {
scrollPositionID = models.first?.id.uuidString
} label: {
Image(systemName: "arrow.up")
}
Button {
scrollPositionID = models.last?.id.uuidString
} label: {
Image(systemName: "arrow.down")
}
}
TextField("Input", text: $text)
.padding()
.background(.ultraThinMaterial, in: .capsule)
.focused($isFocused)
.padding(.horizontal)
}
.padding(.vertical)
.buttonStyle(.bordered)
.background(.regularMaterial)
}
// MARK: - Private
private func makeModels(_ count: Int) -> [Model] {
(0..<count).map { _ in Model() }
}
private func reset() {
models = makeModels(3)
}
}
// MARK: - Color+UUID
private extension Color {
init(from uuid: UUID) {
let hash = uuid.uuidString.hashValue
let r = Double((hash & 0xFF0000) >> 16) / 255.0
let g = Double((hash & 0x00FF00) >> 8) / 255.0
let b = Double(hash & 0x0000FF) / 255.0
self.init(red: abs(r), green: abs(g), blue: abs(b))
}
}
Not working version
When I replace the square view with a text view that generates random multiline text:
struct Model: Identifiable {
let id = UUID()
let text = generateRandomText(range: 1...5)
// MARK: - Utils
private static func generateRandomText(range: ClosedRange<Int>) -> String {
var result = ""
for _ in 0..<Int.random(in: range) {
if let sentence = sentences.randomElement() {
result += sentence
}
}
return result.trimmingCharacters(in: .whitespaces)
}
private static let sentences = [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
]
}
and use it like this:
ForEach(models) { model in
Text(model.text)
.padding()
.multilineTextAlignment(.leading)
.background(Color(from: model.id))
.id(model.id.uuidString)
}
Then on iOS 26, opening the keyboard makes the scroll position jump unpredictably.
It is more visible if you play with the app, but I could not upload a video here.
Environment
Xcode 26.0.1 - Simulators and devices on iOS 26.0 - 18.0
Questions
Is there any known change in ScrollView / scrollPosition(id:) behavior on iOS 26 related to dynamic height content?
Am I missing something in the layout setup that makes this layout unstable with variable-height cells?
Is there a workaround or recommended approach for keeping scroll position stable when keyboard appears?
Hello,
I am writing an audio utility, with a typical audio track player, in SwiftUI for macos 26.
My current problem is that the SwiftUI stops rendering the main window UI when the window loses focus.
This is a problem since even clicking on the app menu bar has the window loose focus, and the timer, time cursor and all animations of the audio piece stop.
All baground services, audio, timers and model continue running (even tho with some crackling on the switch). Once the window focus is re-obtained the animations continue and skip to current state.
I have read that SwiftUI optimizes macos like ios, and disables the ui run loop, but there must be a way to disable, since this obviously not the case for most mac app.
Is there a solution with either SwiftUI or involving AppKit?
Hello,
I'm trying to build a MailKit extension that parses PDFs.
My extension initially gets the call for decide action, I request invokeAgain.
func decideAction(for message: MEMessage, completionHandler: @escaping (MEMessageActionDecision?) -> Void) {
guard let data = message.rawData else {
completionHandler(MEMessageActionDecision.invokeAgainWithBody)
return
}
let content = String(data: data, encoding: .utf8)
print(content)
When I try to reconstruct the PDF attached:
I find the headers, and the text content, but I don't see the base64 content of the PDF file.
Is there something I'm missing here?
Thanks in advance
I am attempting to impliment a a Picker that uses SwiftData to fill in the choices. I am missing something because I can get the picker to appear with the proper selections but the picker does not register my choice (no check mark appears and the text in the picker window is blank after I move to the next field.
The model
import Foundation
import SwiftData
//Model one: type of contract, i.e. Firm Fixed Price, etc
@Model
final class TypeOfContract {
var contracts: [Contract]
@Attribute(.unique) var typeName: String
@Attribute(.unique) var typeCode: String
var typeDescription: String
init(contracts: [Contract], typeName: String = "", typeCode: String = "", typeDescription: String = "") {
self.contracts = contracts
self.typeName = typeName
self.typeCode = typeCode
self.typeDescription = typeDescription
}
}
//Model two: the Contract
@Model
final class Contract {
var contractType: TypeOfContract?
var costReports: [CostReport]
@Attribute(.unique) var contractNumber: String
@Attribute(.unique) var contractName: String
var startDate: Date
var endDate: Date
var contractValue: Decimal
var contractCompany: String
var contractContact: String
var contactEmail: String
var contactPhone: String
var contractNotes: String
init(contractType: TypeOfContract? = nil, costReports: [CostReport], contractNumber: String = "", contractName: String = "", startDate: Date = .now, endDate: Date = .now, contractValue: Decimal = 0.00, contractCompany: String = "", contractContact: String = "", contactEmail: String = "", contactPhone: String = "", contractNotes: String = "") {
self.contractType = contractType
self.costReports = costReports
self.contractNumber = contractNumber
self.contractName = contractName
self.startDate = startDate
self.endDate = endDate
self.contractValue = contractValue
self.contractCompany = contractCompany
self.contractContact = contractContact
self.contactEmail = contactEmail
self.contactPhone = contactPhone
self.contractNotes = contractNotes
}
}
//Model Three: The Cost Reports
@Model
final class CostReport {
var contract: Contract?
var periodStartDate: Date
var periodEndDate: Date
var bCWP: Double //Budgeted Cost Work Performed
var aCWP: Double //Actual Cost Work Performed
var bCWS: Double //Budgeted Cost Work Scheduled
//Calculated fields
init(contract: Contract? = nil, periodStartDate: Date = .now, periodEndDate: Date = .now, bCWP: Double = 0.0, aCWP: Double = 0.0, bCWS: Double = 0.0) {
self.contract = contract
self.periodStartDate = periodStartDate
self.periodEndDate = periodEndDate
self.bCWP = bCWP
self.aCWP = aCWP
self.bCWS = bCWS
}
}
The Swift Code for the input form
import SwiftData
struct EnterNewContract: View {
@Environment(\.modelContext) var modelContext
@Query(sort: \TypeOfContract.typeCode) private var typeOfContracts: [TypeOfContract]
@Query private var contracts: [Contract]
@State private var costReports: [CostReport] = []
@State private var contractType: [TypeOfContract] = []
@State private var contractNumber: String = ""
@State private var contractName: String = ""
@State private var startDate: Date = Date()
@State private var endDate: Date = Date()
@State private var contractValue: Decimal = 0
@State private var contractCompany: String = ""
@State private var contractContact: String = ""
@State private var contactEmail: String = ""
@State private var contactPhone: String = ""
@State private var contractNotes: String = ""
var body: some View {
Form {
VStack {
Section(header: Text("Enter New Contract")
.foregroundStyle(.green)
.font(.headline)){
Picker("Select a type of contract", selection: $contractType) {
ForEach(typeOfContracts, id: \.self) { typeOfContracts in
Text(typeOfContracts.typeCode)
.tag(contractType)
}
}
TextField("Contract Number", text: $contractNumber)
.frame(width: 800, height: 40)
TextField("Contract Name", text: $contractName)
.frame(width: 800, height: 40)
DatePicker("Contract Start Date", selection: $startDate, displayedComponents: [.date])
DatePicker("Contract End Date", selection: $endDate, displayedComponents: [.date])
}
}
}
}
}
Following on from this thread: https://developer.apple.com/forums/thread/805037 my list of items is now correctly maintaining state (no more disappearing rows), but I'm now hitting a really annoying issue: Every time something changes - even just changing the dark mode of the device - the entire list of items is refreshed, and the list jumps back to the top.
A simple representation:
// modelData.filteredItems is either all items or some items, depending on whether the user is searching
List {
ForEach(modelData.filteredItems) { item in
ItemRow(item: item)
}
}
When the user isn't searching, filteredItems has everything in it. When they turn on search, I filter and sort the data in place:
// Called when the user turns on search, or when the searchString or searchType changes
func sortAndFilterItemsInModelData() {
modelData.filteredItems.removeAll() // Remove all items from the filtered array
modelData.filteredItems.append(contentsOf: modelData.allItems) // Add all items back in
let searchString: String = modelData.searchString.lowercased()
switch(modelData.searchType) {
case 1:
// Remove all items from the filtered array that don't match the search string
modelData.filteredItems.removeAll(where: { !$0.name.lowercased().contains(searchString) })
...
}
// Sorting
switch(modelData.sortKey) {
case sortKeyDate:
modelData.sortAscending ? modelData.filteredItems.sort { $0.date < $1.date } : modelData.filteredItems.sort { $0.date > $1.date } // Sorts in place
...
}
}
The method doesn't return anything because all the actions are done in place on the data, and the view should display the contents of modelData.filteredItems.
If you're searching and there are, say 10 items in the list and you're at the bottom of the list, then you change the search so there are now 11 items, it jumps back to the top rather than just adding the extra ItemRow to the bottom. Yes, the data is different, but it hasn't been replaced; it has been altered in place.
The biggest issue here is that you can simply change the device to/from Dark Mode - which can happen automatically at a certain time of day - and you're thrown back to the top of the list. The array of data hasn't changed, but SwiftUI treats it as though it has.
There's also a section in the List that can be expanded and contracted. It shows or hides items of a certain type. When I expand it, I expect the list to stay in the same place and just show the extra rows, but again, it jumps to the top. It's a really poor user experience.
Am I doing something wrong (probably, yes), or is there some other way to retain the scroll position in a List? The internet suggests switching to a LazyVStack, but I lose left/right swipe buttons and the platform-specific styling.
Thanks.
I’m really frustrated with iOS 26. It was supposed to make better use of screen space, but when you combine the navigation bar, tab bar, and search bar, they eat up way too much room.
Apple actually did a great job with the new tab bar — it’s smaller, smooth, and looks great when expanding or collapsing while scrolling. The way the search bar appears above the keyboard is also really nice.
But why did they keep the navigation bar the same height in both portrait and landscape? In landscape it takes up too much space and just looks bad. It was way better in iOS 18.
I've a QLPreviewController in the detail/secondary section of a UISplitViewController and when the user swipes down, it dismisses the entire split view.
Is there a way to prevent this?
Hi, I'm trying to have a menu at the trailing edge of a list but when I do so I am getting UIKit errors. I pasted my sample code below. Not exactly sure how to fix this.
ForEach(0..<100) { i in
HStack {
Text("\(i)")
Spacer()
Menu {
Text("Test")
} label: {
Image(systemName: "ellipsis")
}
}
}
}
Adding '_UIReparentingView' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead.
Topic:
UI Frameworks
SubTopic:
SwiftUI
I am reporting a consistent EXC_BAD_ACCESS (SIGSEGV) crash when using the .contentTransition(.symbolEffect(.replace.byLayer)) modifier on a conditional $SF$ Symbol, but only under very specific conditions:
Both Symbols must be .fill variants (e.g., arrow.up.circle.fill $\leftrightarrow$ plus.circle.fill).
The crash only occurs when the state changes and the view attempts to transition back to the original symbol (the one present when the view was first rendered).
For example, if the initial state displays arrow.up.circle.fill, the app successfully transitions to plus.circle.fill. However, the app crashes when the state changes again, attempting to transition from plus.circle.fill back to arrow.up.circle.fill.This crash is fully reproducible in the iOS Simulator and is not limited to Xcode Previews. Commenting out the .contentTransition modifier resolves the crash immediately.
The crash is a KERN_INVALID_ADDRESS at 0x0000000000000060, pointing to a null pointer dereference deep within the graphics rendering pipeline in the RenderBox framework. It appears to be a failure in handling the layer data during the reverse transition of two filled-variant symbols.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000060
Thread 0 Crashed:
0 RenderBox 0x1cc692a0c RB::Symbol::Glyph::Layer::resolve_draw_transforms(...) + 292
1 RenderBox 0x1cc692730 RB::Symbol::Glyph::Layer::append_path(...) + 392
...
7 SwiftUICore 0x1d9d5f824 specialized _ShapeStyle_RenderedShape.renderVectorGlyph(...) + 1444
The code below crashes on the second tap (transitioning back to arrow.up.circle.fill):
struct QuickAddButtonTest: View {
@State private var isTextFieldFocused: Bool = false
// Both symbols use the .fill variant
var body: some View {
Button(action: {
isTextFieldFocused.toggle()
}) {
Image(systemName: isTextFieldFocused ? "arrow.up.circle.fill" : "plus.circle.fill")
.foregroundColor(.primary)
.font(.system(size: 30))
.contentTransition(.symbolEffect(.replace.byLayer)) // <-- CRASH SOURCE
}
}
}
The crash can be avoided by:
Removing the .contentTransition(.symbolEffect(.replace.byLayer)) modifier, or
Switching one or both symbols to a non-filled variant (e.g., plus.circle instead of plus.circle.fill).
Setting up UITabAccessory via setBottomAccessory(_:animated:) causing recursion internally on iPhone Air which is leading into a crash.
Sharing crash log & feedback below...
crashlog.crash
crash-feedback.json
I have a custom input view in my app which is .focusable(). It behaves similar to a TextField, where it must be focused in order to be used.
This works fine on all platforms including iPad, except when when an external keyboard is connected (magic keyboard), in which case it can't be focused anymore and becomes unusable.
Is there a solution to this, or a workaround? My view is very complex, so simple solutions like replacing it with a native view isn't possible, and I must be able to pragmatically force it to focus.
Here's a very basic example replicating my issue. Non of the functionality works when a keyboard is connected:
struct FocusableTestView: View {
@FocusState private var isRectFocused: Bool
var body: some View {
VStack {
// This text field should focus the custom input when pressing return:
TextField("Enter text", text: .constant(""))
.textFieldStyle(.roundedBorder)
.onSubmit {
isRectFocused = true
}
.onKeyPress(.return) {
isRectFocused = true
return .handled
}
// This custom "input" should focus itself when tapped:
Rectangle()
.fill(isRectFocused ? Color.accentColor : Color.gray.opacity(0.3))
.frame(width: 100, height: 100)
.overlay(
Text(isRectFocused ? "Focused" : "Tap me")
)
.focusable(true, interactions: .edit)
.focused($isRectFocused)
.onTapGesture {
isRectFocused = true
print("Focused rectangle")
}
// The focus should be able to be controlled externally:
Button("Toggle Focus") {
isRectFocused.toggle()
}
.buttonStyle(.bordered)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
}
}
The navigation title color is wrong (dark on dark background) when applying hard scrolledgeeffectstyle.
Illustrated by code example. In simulator or physical device.
Changing scrollEdgeEffectStyle to soft resolves the issue.
As does changing the listStyle.
@main
struct AppView: App {
var body: some Scene {
WindowGroup {
NavigationSplitView {
NavigationStack {
Section {
NavigationLink(destination: OptionsView()) {
Label("More Options", systemImage: "gearshape")
}
.isDetailLink(false)
} header: {
Text("WITH OPTIONS").bold()
}
.navigationTitle("TESTING")
}
} detail: {
Text("DETAIL")
}
.preferredColorScheme(.dark)
}
}
}
struct OptionsView: View {
var body: some View {
List {
Text("List Item")
}
.listStyle(.plain)
.navigationTitle("MORE OPTIONS TITLE")
.scrollEdgeEffectStyle(.hard, for: .all)
}
}
Submittted FB20811402
Bug appears in Landscape mode for iPhone only.
Any orientation for iPad.
Topic:
UI Frameworks
SubTopic:
SwiftUI
In the iOS Photos app there is a caption field the user can write to. How can you write to this value from Swift when creating a photo?
I see apps that do this, but there doesn't seem to be any official way to do this using the Photo library through PHAssetCreationRequest or PHAssetResourceCreationOptions or setting EXIF values, I tried settings a bunch of values there including IPTC values but nothing appears in the caption field in the iOS photos app.
There must be some way to do it since I see other apps setting that value somehow after capturing a photo.
I have a List containing ItemRow views based on an ItemDetails object. The content is provided by a model which pulls it from Core Data.
When I scroll through the list one or two of the rows will disappear and reappear when I scroll back up. I have a feeling it's because the state is being lost?
Here's some relevant info (only necessary parts of the files are provided):
-- ModelData.swift:
@Observable
class ModelData {
var allItems: [ItemDetails] = coreData.getAllItems()
...
}
-- ItemDetails.swift:
struct ItemDetails: Identifiable, Hashable, Equatable {
public let id: UUID = UUID()
public var itemId: String // Also unique, but used for a different reason
...
}
-- MainApp.swift:
let modelData: ModelData = ModelData() // Created as a global
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Methods in here (and in lots of other places) use `modelData`, which is why it's a global
}
@main
struct MainApp: App {
var body: some Scene {
WindowGroup {
MainView()
}
}
...
}
-- MainView.swift:
struct MainView: View {
var body: some View {
List {
ForEach(modelData.allItems, id: \.id) { item in
ItemRow(item)
}
}
}
}
struct ItemRow: View, Equatable {
var item: ItemDetails
var body: some View {
...
}
static func == (lhs: Self, rhs: Self) -> Bool {
lhs.item == rhs.item
}
}
There's obviously more code in the app than that, but it's not relevant to the issue.
I've tried:
ItemRow(item).equatable()
Wrapping ItemRow in an EquatableView
Giving the List a unique id
Using class ModelData: ObservableObject and @StateObject for modelData
None made any difference.
I'm using iOS/iPadOS 26.0.1, and I see it on my physical iPhone 17 Pro Max and iPad Pro 11-inch M4, but I don't see it in the equivalent simulators on those versions. The Simulator also doesn't exhibit this for versions 17.5 and 18.5, and I have no physical devices on 17.5/18.5 to check.
Should I be doing as I currently am, where I create modelData as a global let so I can access it everywhere, or should I pass it through the view hierarchy as an Environment variable, like @Environment(ModelData.self) var modelData: ModelData? Bear in mind that some functions are outside of the view hierarchy and cannot access modelData if I do this. Various things like controllers that need access to values in modelData cannot get to it.
Any ideas? Thanks.
Hi! I am learning Swift and UIKit for work. I am trying to automate using a pickerWheel in VisionOS, but since .adjust(toValue: ) was removed in VisionOS's API, I am absolutely struggling to find a way to set a pickerWheel to a specific value.
Currently, my solution is to calculate the amount of times I would need to increment/decrement the wheel to get from the current value to the desired value, then do so one at a time. However, this currently does not work, as .accessibilityIncrement() and .accessibilityDecrement() do not work, and .swipeUp() and .swipeDown() go too far. What can I do?
Note: I am not a frontend engineer, so while solutions may exist that involve changes to the frontend, I would much rather try and get the frontend we do have to work as is.
Hi,
I develop a 3D molecular editor, so the Writing Tools and AutoFill menu items don't make much sense. Is it possible to hide these menu items in my app? In the case of dictation and the character palette, I can do this:
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"];
Is there some similar way to remove the Writing Tools and AutoFill menu items for apps in which they don't make sense?
Topic:
UI Frameworks
SubTopic:
General
Hello,
this is very weird. I have an app where I use UIDocumentPickerViewController(forOpeningContentTypes: [.folder]) to let the users access to directories that are in the sandbox of other apps. It's been working since iOS 13.
On the beta versions of iOS and iPadOS 26.1 (betas 3 and 4), the second time the UIDocumentPickerViewController is presented, it becomes unresponsive, with a spinning wheel in the top right corner where the "Open" button should be.
I have absolutely no clue what the issue could be. It doesn't seem to be a widespread issue, but I have also no idea on how to find the origin and fix it.
As far as I can tell from the debugger, this line is executed:
DispatchQueue.main.async {
rootVC?.present(self.documentPicker, animated: true, completion: nil)
}
and then nothing else happens.
Topic:
UI Frameworks
SubTopic:
UIKit
In our project, we are now using UIScene, and when click InputText to pull up Keyboard, and when rotate the device, the Keyboard does not update:
how can we fix this issue?