Posts

Post not yet marked as solved
0 Replies
395 Views
When I select text in a text field or regular text view in SwiftUI the text shifts and is cut off and I can only see half of the value on screen. Example of a text field using .textFieldStyle(.plain). Example of text view using .textSelection(.enabled). The text color also changes from white to black when in dark mode. I'm not sure what I'm doing wrong here for these views.
Posted Last updated
.
Post not yet marked as solved
2 Replies
431 Views
I am trying to create this UI using a diffable data source. I have everything working, however, we experience a severe UI hang, between 2200-3000ms, if there are more than 80 sections. It doesn't matter how many items are in the sections, just that there are over 80. Here is the setup for the snapshots. var snapshot = Snapshot() snapshot.appendSections(sections.map(\.branch)) apply(snapshot, animatingDifferences: animatingDifferences) sections.forEach { section in var sectionSnapshot = SectionSnapshot() if let currentBuild = section.builds.first.map({ SectionItem.currentBuild($0) }) { sectionSnapshot.append([currentBuild]) } if section.builds.count > 1 { let additionalBuildsHeader = SectionItem.additionalBuildsHeader(forSection: section.branch) sectionSnapshot.append([additionalBuildsHeader]) let additionalBuilds = section.builds .dropFirst() .map({ SectionItem.additionalBuild($0) }) sectionSnapshot.append(additionalBuilds, to: additionalBuildsHeader) if expandedSections.contains(additionalBuildsHeader) { sectionSnapshot.expand([additionalBuildsHeader]) } } apply(sectionSnapshot, to: section.branch, animatingDifferences: animatingDifferences) } I tried to do this with a single data source snapshot, instead of using the section snapshots and then the UI does not experience any hangs. While this works, we don't get the nice collapsible sections and all builds are displayed at the same level. Here is the code for that setup. var snapShot = Snapshot() snapShot.appendSections(sections.map(\.branch)) sections.forEach { section in     if let currentBuild = section.builds.first.map({ SectionItem.currentBuild($0) }) {         snapShot.appendItems([currentBuild], toSection: section.branch)     } if section.builds.count > 1 {         let additionalBuilds = section.builds                 .dropFirst()                 .map({ SectionItem.additionalBuild($0) })         snapShot.appendItems(additionalBuilds, toSection: section.branch)     } } apply(snapShot, animatingDifferences: animatingDifferences) Am I doing something wrong here with this setup in using the section snapshots? It seems like the hangs might be due to a layout pass being triggered on each apply, but I don't know any other way to build the section snapshots.
Posted Last updated
.
Post not yet marked as solved
7 Replies
3.7k Views
I'm embarrassed to ask this because I feel like I am just missing something super simple.In our app we keep a search history of destinations that the user searches for. I wanted to make these available to Spotlight and Siri suggestions. When I add the history items to Spotlight everything behaves as expected. I can see the items in Spotlight, select them and it triggers the search again for that specific history item. When I add the item to the search index I am also creating an NSUserActivity object and setting it to current so that we can also benefit from Handoff. Where my issue is happening is when I try to set the NSUserActivity to eligible for prediction and add a persistent identifier for the Siri suggestions. When I do this and I perform a search then I do still see the spotlight indexed item as well as a suggestion by Siri as expected. However, if I do a second search, even for the same item, when I try to access Spotlight to see my entries then I get a SpringBoard crash.I was previously doing this without Spotlight and just using NSUserActivity, but realized that wasn't the right approach, since I also need to delete items from the index if the user deletes their history in the app. When I was just using NSUserActivity it did not crash, but the indexing in Spotlight was not what I wanted and would disappear after a time. But I don't know what I have done wrong with setting up the Spotlight index and setting the NSUserActivity that would cause a SpringBoard crash when donating more than one item.A brief bit about our setup:* I have created an ActivityHandler class that pulls the necessary info together to donate everything.* Our backend target will pass the necessary data to the ActivityHandler class based on the user actions of performing a search or tapping on a search history item.* In the ActivityHandler I am setting up the Spotlight item first and adding it to the index.* In the completion handler of CSSearchableIndex I am setting up the user activity, setting it to becomeCurrent and then adding it to a property in the class that holds it so that it is not deallocated after the method ends.I am completely stumped on what I am doing wrong. Any insights from anybody would be greatly appreciated. 🙂I just tried and installed a build on a device with iOS 13 beta 7 and it works as expected. The previous device and simulator version that I was testing on was iOS 12.0 and 12.4.
Posted Last updated
.