I’m working with AppIntents and AppEntity to integrate my app’s data model into Shortcuts and Siri. In the example below, I define a custom FoodEntity and use it as a @Parameter in an AppIntent. I’m providing dynamic options for this parameter via an optionsProvider.
In the Shortcuts app, everything works as expected: when the user runs the shortcut, they get a list of food options (from the dynamic provider) to select from.
However, in Siri, the experience is different. Instead of showing the list of options, Siri asks the user to say the name of the food, and then tries to match it using EntityStringQuery.
I originally assumed this might be a design decision to allow hands-free use with voice, but I found that if you use an AppEnum instead, Siri does present a tappable list of options. So now I’m wondering: why the difference?
Is there a way to get the @Parameter with AppEntity + optionsProvider to show a tappable list in Siri like it does in Shortcuts or with an AppEnum?
Any clarification on how EntityQuery.suggestedEntities() and DynamicOptionsProvider interact with Siri would be appreciated!
struct CaloriesShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: AddCaloriesInteractive(),
phrases: [
"Add to \(.applicationName)"
],
shortTitle: "Calories",
systemImageName: "fork"
)
}
}
struct AddCaloriesInteractive: AppIntent {
static var title: LocalizedStringResource = "Add to calories log"
static var description = IntentDescription("Add Calories using Shortcuts.")
static var openAppWhenRun: Bool = false
static var parameterSummary: some ParameterSummary {
Summary("Calorie Entry SUMMARY")
}
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(stringLiteral:"Add to calorie log")
}
@Dependency
private var persistenceManager: PersistenceManager
@Parameter(title: LocalizedStringResource("Food"), optionsProvider: FoodEntityOptions())
var foodEntity: FoodEntity
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
return .result(dialog: .init("Added \(foodEntity.name) to calorie log"))
}
}
struct FoodEntity: AppEntity {
static var defaultQuery = FoodEntityQuery()
@Property var name: String
@Property var calories: Int
init(name: String, calories: Int) {
self.name = name
self.calories = calories
}
static var typeDisplayRepresentation: TypeDisplayRepresentation {
TypeDisplayRepresentation(name: "Calorie Entry")
}
static var typeDisplayName: LocalizedStringResource = "Calorie Entry"
var displayRepresentation: AppIntents.DisplayRepresentation {
DisplayRepresentation(title: .init(stringLiteral: name), subtitle: "\(calories)")
}
var id: String {
return name
}
}
struct FoodEntityQuery: EntityQuery {
func entities(for identifiers: [FoodEntity.ID]) async throws -> [FoodEntity] {
var result = [FoodEntity]()
for identifier in identifiers {
if let entity = FoodDatabase.allEntities().first(where: { $0.id == identifier }) {
result.append(entity)
}
}
return result
}
func suggestedEntities() async throws -> [FoodEntity] {
return FoodDatabase.allEntities()
}
}
extension FoodEntityQuery: EntityStringQuery {
func entities(matching string: String) async throws -> [FoodEntity] {
return FoodDatabase.allEntities().filter({$0.name.localizedCaseInsensitiveCompare(string) == .orderedSame})
}
}
struct FoodEntityOptions: DynamicOptionsProvider {
func results() async throws -> ItemCollection<FoodEntity> {
ItemCollection {
ItemSection("Section 1") {
for entry in FoodDatabase.allEntities() {
entry
}
}
}
}
}
struct FoodDatabase {
// Fake data
static func allEntities() -> [FoodEntity] {
[
FoodEntity(name: "Orange", calories: 2),
FoodEntity(name: "Banana", calories: 2)
]
}
}
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
Activity
I released an app for iPhone (and it's could be downloaded for iPad also), and now I developered another app for iPad version with the same code and logic but I modified the layout to fit bigger screen and make better user experience and appearance.
Howevert the app review rejected my release due to the duplicate content, how can I solve it?
Topic:
UI Frameworks
SubTopic:
General
I've been looking for a solution to configure the Apple TV remote(s) from the 5th generation and upwards.
Some of the basic functionalities are disabling buttons on the physical remote control while maintaining proper functionality on remote controller apps on iOS devices.
There seems to be a lack of relevant entitlements in that category, and without it I can't seem to figure out a way to make it work.
Any ideas on the matter?
Maybe a workaround that allows to configure the Apple TV to work with other remotes?
Thank you in advance to anyone that put in thought to my query.
I want to add the option to choose an alternative icon inside the app.
Is there a way to load an icon asset from within the app? I downloaded Apple’s alternative icon sample, which is supposed to show a list of icons to choose from, but even in the sample, it did not work.
So the current solution is to add every alternative icon along with another image asset of the same image to display to the user. This sounds like a waste of bytes.
Thank you in advance for any help.
Topic:
UI Frameworks
SubTopic:
General
In SwiftUI for macOS, how can I animate the transition from one Tab to another Tab within TabView when the selection changes?
In AppKit, we can do the following:
let tabViewController = NSTabViewController()
tabViewController.transitionOptions = [.crossfade, .allowUserInteraction]
How can I achieve the same crossfade effect when using TabView?
I have a custom keypad to accept numeric input for iPads that I have been using for many years now. This is longstanding working code. With iOS 18 the touchUpInside (and other) events in the underlying Objective-C modules are not called in the file owner module when activated from the interface. The buttons seem to be properly activated based on the visual cues (they change colors when pressed). This is occurring in both simulators and on hardware. Setting the target OS version does not help. What could the cause and/or solution of this be?
It looks like I'm one of the rare developers dealing with CarPlay...
I develop a CarPlay extension for my apps. A few things:
especially when using the CarPlay I/O window in iOS Simulator, I get random selection highlightning for list items: I have three list templates in a tab template; once I reselect a list using the tab which has been selected before, the initial list item highlights / returns to normal every refresh of the list content; while this doesn't happen for my real world Sony CarPlay device, I'd rather not see such disturbing highlighting for my users. I do not update the template structs or items here, it is just content like text of detailText I update. Question: how to remove highlightning programmatically - especially for devices with touch screen?
I have one user who reports auto-selection of UI elements while driving; I assume this is some problem with his touch screen, but it may be a general issue too. Question: anyone with similar observations
connecting my iPhone to the stand-alone Car Play simulator doesn't work; I had it working before, so it might be related to a recent iOS beta...
Any hints / observations are welcome. The CarPlay community really seems to be small and I'd like to hear other's experience on the named items.
Hi everyone,
frome time to time I see crash which Im not able to debug, because there is no line of my code where crash occured.
This is a crash log what Im getting from time to time of some users. In my device I never get this kind of crash.
0 libswiftCore.dylib 0x1172c _assertionFailure(_:_:flags:) + 208
1 libswiftCore.dylib 0x198624 KEY_TYPE_OF_DICTIONARY_VIOLATES_HASHABLE_REQUIREMENTS(_:) + 2980
2 libswiftCore.dylib 0xdb6c8 specialized _NativeDictionary.uncheckedRemove(at:isUnique:) + 534
3 libswiftCore.dylib 0xb250c Dictionary._Variant.setValue(_:forKey:) + 204
4 libswiftCore.dylib 0x5a620 Dictionary.subscript.setter + 520
5 SwiftUICore 0xf62ec ForEachState.item(at:offset:) + 4340
6 SwiftUICore 0xf5054 ForEachState.forEachItem(from:style:do:) + 1796
7 SwiftUICore 0x2272f8 ForEachState.traitKeys.getter + 84
8 SwiftUICore 0x227298 ForEachList.traitKeys.getter + 24
9 SwiftUICore 0x227008 protocol witness for ViewList.traitKeys.getter in conformance SubgraphList + 76
10 SwiftUICore 0x227008 protocol witness for ViewList.traitKeys.getter in conformance SubgraphList + 76
11 SwiftUICore 0x227008 protocol witness for ViewList.traitKeys.getter in conformance SubgraphList + 76
12 SwiftUICore 0x227008 protocol witness for ViewList.traitKeys.getter in conformance SubgraphList + 76
13 SwiftUICore 0x2271fc DynamicViewList.WrappedList.traitKeys.getter + 88
27 SwiftUICore 0x226d18 specialized static SectionAccumulator.processUnsectionedContent(list:contentSubgraph:) + 84
28 SwiftUI 0x26afe0 ListSectionInfo.init(list:listAttribute:contentSubgraph:) + 132
29 SwiftUI 0x269bb0 UpdateCollectionViewListCoordinator.updateValue() + 1528
30 SwiftUI 0x785d4 partial apply for implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 32
31 AttributeGraph 0xccac AG::Graph::UpdateStack::update() + 540
32 AttributeGraph 0xc870 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, unsigned int) + 424
33 AttributeGraph 0xc444 AG::Subgraph::update(unsigned int) + 848
34 SwiftUICore 0x805a8 GraphHost.flushTransactions() + 860
35 SwiftUI 0x1ac84 closure #1 in _UIHostingView._renderForTest(interval:) + 24
36 SwiftUICore 0x7ffa8 partial apply for closure #1 in ViewGraphDelegate.updateGraph<A>(body:) + 28
37 SwiftUICore 0x7fd6c ViewRendererHost.updateViewGraph<A>(body:) + 120
38 SwiftUICore 0x7fce8 ViewGraphDelegate.updateGraph<A>(body:) + 84
39 SwiftUI 0x3e688 closure #1 in closure #1 in closure #1 in _UIHostingView.beginTransaction() + 172
40 SwiftUI 0x3e5d4 partial apply for closure #1 in closure #1 in closure #1 in _UIHostingView.beginTransaction() + 24
41 SwiftUICore 0x79720 closure #1 in static Update.ensure<A>(_:) + 56
42 SwiftUICore 0x796a4 static Update.ensure<A>(_:) + 100
43 SwiftUI 0x9c808 partial apply for closure #1 in closure #1 in _UIHostingView.beginTransaction() + 80
44 SwiftUICore 0x7f5e0 thunk for @callee_guaranteed () -> () + 28
45 SwiftUICore 0x6161c specialized closure #1 in static NSRunLoop.addObserver(_:) + 144
46 CoreFoundation 0x218a4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
47 CoreFoundation 0x213f8 __CFRunLoopDoObservers + 552
48 CoreFoundation 0x75da8 __CFRunLoopRun + 948
49 CoreFoundation 0xc8284 CFRunLoopRunSpecific + 588
50 GraphicsServices 0x14c0 GSEventRunModal + 164
51 UIKitCore 0x3ee674 -[UIApplication _run] + 816
52 UIKitCore 0x14e88 UIApplicationMain + 340
53 SwiftUI 0x291ef8 closure #1 in KitRendererCommon(_:) + 168
54 SwiftUI 0x291e28 runApp<A>(_:) + 100
55 SwiftUI 0x291d0c static App.main() + 180
56 DholRainbow 0x3019e8 main + 4339145192 (DholRainbowApp.swift:4339145192)
57 ??? 0x1b0bf5de8 (Missing)
From Crashlytics I know at least human readable format of this error
Fatal error: Duplicate keys of type 'Contact' were found in a Dictionary. This usually means either that the type violates Hashable's requirements, or that members of such a dictionary were mutated after insertion.
I 've checked all my parts of code where Im using dictionary. This is a function which creating that particulary dictionary.
private func logsByDate() {
let groupedByDate = Dictionary(grouping: logs.filter { ($0.remoteParty as? Contact != nil) } ) {
$0.date.removeTimeStamp ?? .distantPast }.mapValues {
$0.compactMap { $0 }
}
var dayLogs = [DayLog]()
for date in groupedByDate {
var contacts = [CallLogContact]()
for log in logs.filter({ $0.date.removeTimeStamp ?? .distantPast == date.key }) {
if let contact = log.remoteParty as? Contact {
if contacts.firstIndex(where: {$0.contact == contact }) == nil {
let contactDayLogs = logs.filter({ $0.remoteParty as? Contact == contact && $0.date.removeTimeStamp == date.key})
contacts.append(
CallLogContact(
contact: contact,
logs: contactDayLogs,
lastCallLogDate: contactDayLogs.sorted(by: {$0.date > $1.date}).first?.date ?? .distantPast
)
)
}
}
}
dayLogs.append(DayLog(date: date.key, contact: contacts))
}
DispatchQueue.main.async {
self.groupedCallLogs = dayLogs
}
}
This function is called from 3 others functions based on notification from the server in case of new call log, fetched call logs and removed call logs.
I have a macOS application developed in SwiftUI. It's a document-based application. I know how to hide the Show Tab Bar command under View. I don't want to hide it. I always want to show tabs. I wonder how to enable this command programmatically such that the document window always has the + button to the right. Thanks.
how can i watch the LiveCommunicationKit event?
i have codes likes this:
import UIKit
import LiveCommunicationKit
@available(iOS 17.4, *)
class LiveCallKit: NSObject, ConversationManagerDelegate {
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, conversationChanged conversation: Conversation) {
}
@available(iOS 17.4, *)
func conversationManagerDidBegin(_ manager: ConversationManager) {
}
@available(iOS 17.4, *)
func conversationManagerDidReset(_ manager: ConversationManager) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, perform action: ConversationAction) {
switch action.state
{
case .idle:
self.completionHandler!(InterfaceKind.reject,self.payload!)
case .running:
self.completionHandler!(InterfaceKind.reject,self.payload!)
case .complete:
self.completionHandler!(InterfaceKind.reject,self.payload!)
case .failed(let reason):
self.completionHandler!(InterfaceKind.reject,self.payload!)
default:
self.completionHandler!(InterfaceKind.reject,self.payload!)
}
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, timedOutPerforming action: ConversationAction) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, didActivate audioSession: AVAudioSession) {
}
@available(iOS 17.4, *)
func conversationManager(_ manager: ConversationManager, didDeactivate audioSession: AVAudioSession) {
}
@objc public enum InterfaceKind : Int, Sendable, Codable, Hashable {
/// 拒绝/挂断
case reject
/// 接听.
case answer
}
var sessoin: ConversationManager
var callId: UUID
var completionHandler: ((_ actionType: InterfaceKind,_ payload: [AnyHashable : Any]) -> Void)?
var payload: [AnyHashable : Any]?
@objc init(icon: UIImage!) {
let data:Data = icon.pngData()!;
let cfg: ConversationManager.Configuration = ConversationManager.Configuration(ringtoneName: "ring.mp3",
iconTemplateImageData: data,
maximumConversationGroups: 1,
maximumConversationsPerConversationGroup: 1,
includesConversationInRecents: false,
supportsVideo: false,
supportedHandleTypes: Set([Handle.Kind.generic]))
self.sessoin = ConversationManager(configuration: cfg)
self.callId = UUID()
super.init()
self.sessoin.delegate = self
}
@objc func toIncoming(_ payload: [AnyHashable : Any], displayName: String,actBlock: @escaping(_ actionType: InterfaceKind,_ payload: [AnyHashable : Any])->Void) async {
self.completionHandler = actBlock
do {
self.payload = payload
self.callId = UUID()
var update = Conversation.Update(members: [Handle(type: .generic, value: displayName, displayName: displayName)])
let actNumber = Handle(type: .generic, value: displayName, displayName: displayName)
update.activeRemoteMembers = Set([actNumber])
update.localMember = Handle(type: .generic, value: displayName, displayName: displayName);
update.capabilities = [ .playingTones ];
try await self.sessoin.reportNewIncomingConversation(uuid: self.callId, update: update)
try await Task.sleep(nanoseconds: 2000000000);
} catch {
}
}
}
i want to watch the buttons action,how should i do?
Topic:
UI Frameworks
SubTopic:
SwiftUI
I am working on creating a custom Popup View based on a .fullscreenCover. The .fullscreenCover is used to place the Popup content on screen on a semi-transparent background.
While this works on iOS 18, there is a problem on iOS 17: When the Popup content contains a .sheet, the background is not transparent any more but opaque.
Image: iOS 17. When showing the Popup an opaque background covers the main content. When tapping on the background it turns transparent.
Image: iOS 18. Everything works as intended. When showing the Popup the main background is covered with a semi-transparent background.
Removing the .sheet(...) from the Popup content solves the problem. It does not matter if the sheet is used or not. Adding it to the view code is enough to trigger the problem.
Using a .sheet within a .fullscreenCover should not be a problem as far as I know.
Is this a bug in iOS 17 or is there something wrong with my code?
Code:
struct SwiftUIView: View {
@State var isPresented: Bool = false
@State var sheetPresented: Bool = false
var body: some View {
ZStack {
VStack {
Color.red.frame(maxHeight: .infinity)
Color.green.frame(maxHeight: .infinity)
Color.yellow.frame(maxHeight: .infinity)
Color.blue.frame(maxHeight: .infinity)
}
Button("Show") {
isPresented = true
}
.padding()
.background(.white)
Popup(isPresented: $isPresented) {
VStack {
Button("Dismiss") {
isPresented = false
}
}
.frame(maxWidth: 300)
.padding()
.background(
RoundedRectangle(cornerRadius: 20)
.fill(.white)
)
.sheet(isPresented: $sheetPresented) {
Text("Hallo")
}
}
}
}
}
struct Popup<Content: View>: View {
@Binding var isPresented: Bool
let content: () -> Content
init(isPresented: Binding<Bool>, @ViewBuilder _ content: @escaping () -> Content) {
_isPresented = isPresented
self.content = content
}
@State private var internalIsPresented: Bool = false
@State private var isShowing: Bool = false
let transitionDuration: TimeInterval = 0.5
var body: some View {
ZStack { }
.fullScreenCover(isPresented: $internalIsPresented) {
VStack {
content()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(
Color.black.opacity(0.5)
.opacity(isShowing ? 1 : 0)
.animation(.easeOut(duration: transitionDuration), value: isShowing)
.ignoresSafeArea()
)
.presentationBackground(.clear)
.onAppear {
isShowing = true
}
.onDisappear {
isShowing = false
}
}
.onChange(of: isPresented) { _ in
withoutAnimation {
internalIsPresented = isPresented
}
}
}
}
extension View {
func withoutAnimation(action: @escaping () -> Void) {
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
action()
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
I’m having a weird UIKit problem. I have a bunch of views in a UIScrollView and I add a UIContextMenuInteraction to all of them when the view is first loaded. Because they're in a scroll view, only some of the views are initially visible.
The interaction works great for any of the views that are initially on-screen, but if I scroll to reveal new subviews, the context menu interaction has no effect for those.
I used Xcode's View Debugger to confirm that my interaction is still saved in the view's interactions property, even for views that were initially off-screen and were then scrolled in.
What could be happening here?
Subject: SwiftUI Gesture Conflict in iOS 18: Simultaneous Recognition of Drag and Tap Gestures
Description:
In SwiftUI on iOS 18 and above, we've identified an issue with gesture handling that affects user experience. When implementing .simultaneousGesture(DragGesture()), the system incorrectly recognizes and processes both drag and tap gestures concurrently, resulting in unintended behavior.
Technical Details:
Environment: SwiftUI, iOS 18+
Issue: Simultaneous recognition of horizontal drag gestures and vertical scroll/tap gestures
Current Behavior: Both vertical and horizontal scrolling occur simultaneously when using .simultaneousGesture(DragGesture())
Expected Behavior: Gestures should be properly disambiguated to prevent concurrent scrolling in multiple directions
Impact:
This behavior significantly impacts user experience, particularly in custom carousel implementations and other UI components that rely on precise gesture handling. The simultaneous recognition of both gestures creates a confusing and unpredictable interaction pattern.
Steps to Reproduce:
Create a SwiftUI view with horizontal scrolling (e.g., custom carousel)
Implement .simultaneousGesture(DragGesture())
Add tap gesture recognition to child views
Run on iOS 18
Attempt to scroll horizontally
Observed Result:
Both horizontal dragging and vertical scrolling/tapping are recognized and processed simultaneously, creating an inconsistent user experience.
Expected Result:
The system should properly disambiguate between horizontal drag gestures and vertical scroll/tap gestures, allowing only one type of gesture to be recognized at a time based on the user's intent.
Please let me know if you need any additional information or reproduction steps.
I am new to the idea of Siri Shortcuts and App Intents. What I want to do is use Siri to run a function in my app.
Such as saying to Siri Zoom in map and that will then call a function in my app where I can zoom in the map. Similarly, I could say Zoom out map and it would call a function to zoom out my map.
I do not need to share any sort of shortcut with the Shortcuts app.
Can someone please point me in the right direction for what type of intents I need to use for this?
When using New Password Autofill in Dark Mode, it appears that SecureEntry sets the background color to white and applies a yellow-ish overlay, but doesn't adapt the foreground text color accordingly. This gives the illusion that the SecureEntry field is empty, as we have white text on a white background.
Is there a holistic and SwiftUI-native way of fixing this?
At this line of code (SketchTextSelectionManager.swift:449), sometimes there will be crashes based on crashlytics reports.
let selection = pdfPage.selectionForWord(at: location)
This is directly calling into PDFKit's PDFPage#selection method: https://developer.apple.com/documentation/pdfkit/pdfpage/selectionforword(at:)
Attached the full stacktrace:
Crashed: com.apple.root.user-initiated-qos.cooperative
0 CoreGraphics 0x30c968 PageLayout::getWordRange(unsigned long, long) const + 908
1 CoreGraphics 0x30bbc0 PageLayout::getTextRangeIndex(CGPoint, CGPDFSelectionType, SelectionPrecision) const + 2292
2 CoreGraphics 0x44a53c CGPDFSelectionCreateBetweenPointsWithOptions + 384
3 PDFKit 0x8d5f8 -[PDFPage selectionFromPoint:toPoint:type:] + 168
4 PDFKit 0x92040 -[PDFPage _rvItemAtPoint:] + 64
5 PDFKit 0x91f4c -[PDFPage rvItemAtPoint:] + 84
6 PDFKit 0x8caa8 -[PDFPage selectionForWordAtPoint:] + 40
7 MyApp 0x8420e0 closure #1 in SketchTextSelectionManager.startNewTextSelection(pageId:location:) + 449 (SketchTextSelectionManager.swift:449)
8 MyApp 0x841a70 SketchTextSelectionManager.startNewTextSelection(pageId:location:) + 205 (CurrentNoteManager.swift:205)
9 libswift_Concurrency.dylib 0x61104 swift::runJobInEstablishedExecutorContext(swift::Job*) + 252
10 libswift_Concurrency.dylib 0x63a28 (anonymous namespace)::ProcessOutOfLineJob::process(swift::Job*) + 480
11 libswift_Concurrency.dylib 0x611c4 swift::runJobInEstablishedExecutorContext(swift::Job*) + 444
12 libswift_Concurrency.dylib 0x62514 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 144
13 libdispatch.dylib 0x15d8c _dispatch_root_queue_drain + 392
14 libdispatch.dylib 0x16590 _dispatch_worker_thread2 + 156
15 libsystem_pthread.dylib 0x4c40 _pthread_wqthread + 228
16 libsystem_pthread.dylib 0x1488 start_wqthread + 8
```
Let's say you have a protocol that can work with both classes and structs but you want to have a uniform UI to make edits.
What is the recommended way to have one view that will take both?
App
import SwiftUI
@main
struct ObservationTesterApp: App {
var body: some Scene {
WindowGroup {
ContentView(existence: Existence())
}
}
}
Types
import Foundation
protocol Dateable {
var timestamp:Date { get set }
}
struct Arrival:Dateable {
var timestamp:Date
}
@Observable
class Existence:Dateable {
var timestamp:Date
init(timestamp: Date) {
self.timestamp = timestamp
}
}
extension Existence {
convenience init() {
self.init(timestamp: Date())
}
}
ContentView, etc
//
// ContentView.swift
// ObservationTester
//
//
import SwiftUI
struct EditDateableView<TimedThing:Dateable>:View {
@Binding var timed:TimedThing
//note that this currently JUST a date picker
//but it's possible the protocol would have more
var body:some View {
DatePicker("Time To Change", selection: $timed.timestamp)
}
}
#Preview {
@Previewable @State var tt = Arrival(timestamp: Date())
EditDateableView<Arrival>(timed: $tt)
}
struct ContentView: View {
@State var arrival = Arrival(timestamp: Date())
@Bindable var existence:Existence
var body: some View {
//this work around also not allowed. "self is immutable"
// let existBinding = Binding<Existence>(get: { existence }, set: { existence = $0 })
VStack {
EditDateableView(timed: $arrival)
//a Binding cant take a Bindable
//EditDateableView<Existence>(timed: $existence)
}
.padding()
}
}
#Preview {
ContentView(existence: Existence())
}
I have a popover/sheet in iOS which allows users to search and add items to a list. When the sheet is shown, the search should always be active.
I am using searchable on a NavigationStack inside the sheet. I am using the isPresented parameter to activate search.
My issue is with the animation of the search activation. Even if I use...
isPresented: .constant(true)
...the search isn't activated until the sheet has completed it's entrance animation, resulting in two stages of animation.
I can't add a video here, but the two images below show the steps I am seeing. First a slide up animation, with the search in the navigation drawer, then a second animation, once the sheet is fully in place, as the search becomes active.
Is it possible to merge these two animations, so search is in place when the sheet animates up?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Description:
When initiating the print flow via UIPrintInteractionController, and no printer is initially connected, iOS displays all possible paper sizes in the paper selection UI. However, if a printer connects in the background after this view is shown, the list of paper sizes does not automatically refresh to reflect only the options supported by the connected printer.
If the user selects an incompatible paper size (one not supported by the printer that has just connected), the app crashes due to an invalid configuration.
Steps to Reproduce:
Launch the app and navigate to the print functionality.
Tap the Print button to invoke UIPrintInteractionController.
At this point, no printer is yet connected. iOS displays all available paper sizes.
While the paper selection UI is visible, the AirPrint-compatible printer connects in the background.
Without dismissing the controller, the user selects a paper size (e.g., one that is not supported by the printer).
The app crashes.
Expected Result: App should not crash
Once the printer becomes available (connected in the background), the paper size options should refresh automatically.
The list should be filtered to only include sizes that are compatible with the connected printer.
This prevents the user from selecting an invalid option, avoiding crashes.
Actual Result: App crashes
The paper size list remains unfiltered.
The user can still select unsupported paper sizes.
Selecting an incompatible option causes the app to crash, due to a mismatch between UI selection and printer capability.
Topic:
UI Frameworks
SubTopic:
UIKit
on iOS you can choose to scale to view to have the app resize the screen easily in the developer environment. Scale to view is however not easily done on MacOS using NS to solve on MacOS now. Is it possible for the Apple developer team to make this easier for the Developer, as I understand it is for iOS applications?