Post

Replies

Boosts

Views

Activity

Reply to Device UDID
That functionality was disabled a long time ago due to privacy concerns. You can get an identifier that remains the same as long as one of your apps is installed, but if they are deleted and installed again, a new one is assigned... https://developer.apple.com/documentation/uikit/uidevice identifierForVendor
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’23
Reply to Crash when triggering sheet presentation from a task
I found a solution import PlaygroundSupport import SwiftUI struct SheetView: View { @Binding var content: String? init(_ content: Binding<String?>) { _content = content } var body: some View { Text(content!) } } struct ContentView: View { @State private var isPresented = false @State private var content: String? @State private var startTask = false var body: some View { Text("Tap me") .onTapGesture { startTask = true } .frame(width: 500.0, height: 500.0) .task(id: startTask) { guard startTask else { // startTask = false // <===== Crashes if removed content = "Some message" isPresented = true } .sheet(isPresented: $isPresented) { SheetView($content) } } } let view = ContentView() PlaygroundPage.current.setLiveView(view)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to Crash when triggering sheet presentation from a task
I think I know the problem. You are accessing the content property value as it is at that moment, but you access the isPresented property in what amounts to the will set call, so you are seeing the future presented value, but the present content. I'm not sure of a fix for it since it becomes immutable if you remove the state wrapper.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to Command Center media buttons is not syncing with App's media state Swift
Your app needs to update the control state, enable/disable, based on its control state. I have this function that handles a change in the player state /// updates the media player controls to reflect the new player status /// - Parameter status: player status flags func updateUI(status: PlayerStatus) { ModuleData.singleton.mediaCommandCenter.playCommand.isEnabled = status.intersects(with: .play) ModuleData.singleton.mediaCommandCenter.stopCommand.isEnabled = status.intersects(with: .stop) ModuleData.singleton.mediaCommandCenter.pauseCommand.isEnabled = status.intersects(with: .pause) ModuleData.singleton.mediaCommandCenter.nextTrackCommand.isEnabled = status.intersects(with: .skipForward) ModuleData.singleton.mediaCommandCenter.togglePlayPauseCommand.isEnabled = status.intersects(with: [.stop, .play, .pause]) ModuleData.singleton.mediaCommandCenter.previousTrackCommand.isEnabled = status.intersects(with: .skipBackward) ModuleData.singleton.mediaCommandCenter.skipForwardCommand.isEnabled = status.intersects(with: .skipBackwardTime) ModuleData.singleton.mediaCommandCenter.skipBackwardCommand.isEnabled = status.intersects(with: .skipBackwardTime) ModuleData.singleton.mediaCommandCenter.seekForwardCommand.isEnabled = status.intersects(with: .seekForward) ModuleData.singleton.mediaCommandCenter.seekBackwardCommand.isEnabled = status.intersects(with: .seekBackward) } The status values are a bit mask enum with various controls enabled/disabled.
Topic: Media Technologies SubTopic: General Tags:
Apr ’23
Reply to How to hide share/action button from QLPreviewController in iOS 10.X
One additional horrible hack is to check the right bar button items list to see if it has more items than you expect, and if so, drop the first one. In my case I was expecting one, so I set it to be just the last item in the list. I have the advantage of not needing my app to go to the store, so I don't know if this combination of things would be allowed in store apps.
Topic: App & System Services SubTopic: General Tags:
Mar ’22
Reply to How to hide share/action button from QLPreviewController in iOS 10.X
The best I managed with it being presented full screen is to set the right navigation item to be a close button and set the navigation controller toolbar as hidden in viewDidLoad. This leaves a blank toolbar, but that at least gets rid of the share button. Looking at the screen using xcode's view inspector, it looks like it might be creating a toolbar since I see two toolbars stacked on one another, a blank one and the one with the share button. I also set the toolbar to hidden in willLayoutSubviews That works on a compact screen, aka portrait on a phone, but in landscape the share button becomes a second button to the left of my close button. I just spotted the landscape issue and am still looking into it.
Topic: App & System Services SubTopic: General Tags:
Mar ’22