Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Preview crashes on simple code
"padding()" should be ".padding()" As in: struct ContentView: View { var body: some View { VStack { Text("Hello, world!") .padding() Text("Another Line") } } } "padding()" is an instance method, so calling it without the leading ".", as you do, probably causes something horrible to happen, which causes the crash. (Since it will return a function, not a View)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Can I use api `UIApplicationVolumeUpButtonDownNotification` for getting volume up/down button?
AVAudioSession has a property "outputVolume". You could look for changes to this, using Key-value observing... ...and use that to trigger your photo. That might go against rule 2.5.9, but since Apple's Camera app uses the volume buttons, I think it should be okay. (Note: this technique does not work in the Simulator, it needs a real device) Perhaps something like this: import AVFAudio class VolumeButtonObserver { let audioSession = AVAudioSession.sharedInstance() var outputVolumeObservation: NSKeyValueObservation? init() { observeVolumeButtons() } func observeVolumeButtons() { do { try audioSession.setActive(true) } catch {} outputVolumeObservation = audioSession.observe(\.outputVolume) { (audioSession, changes) in print("A volume button was pressed") /// Take action here... } } }
Jan ’22
Reply to iMac can’t recognize Logitech keyboard and mouse on login
Yes this seems to be a problem, where certain bluetooth devices are not recognized, before logging in. Which makes it difficult to login! I had a recent trauma with this, when booting in Recovery mode... I had to dig out an ancient wired mouse. I will be interested to see if anyone has a solution to this. iMac Pro MK Anywhere 2 mouse Wired keyboard (to get round this issue!)
Topic: App & System Services SubTopic: Hardware Tags:
Jan ’22
Reply to Pass a Timer through Controllers
I also wish for the user to be able to close the app and have the timer run in the background The timer will not run in the background, but here is a technique that you could use: Add a mechanism to detect when the app is entering the background, or foreground On backgrounding: If your timer is live... Convert it to a notification (calculate the fire date from the timer expiry) Cancel the timer If the timer expires while the app is backgrounded, the user will see the notification On foregrounding: Remove pending notifications Restart the timer, if it has not expired
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’22
Reply to import pdf from url
PDFDocument(url:) returns an Optional value... Try this: func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let url = urls.first else {         print("Error: no url") return } guard let dokument = PDFDocument(url: url) else { print("Error: could not create PDFDocument from url: \(url)") return } dokumnetpdf = dokument }
Jan ’22
Reply to import pdf from url
It looks like a permissions issue. Try this: func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let url = urls.first else { print("Error: no url") return } guard url.startAccessingSecurityScopedResource() else { print("Error: could not access content of url: \(url)") return } guard let dokument = PDFDocument(url: url) else { print("Error: could not create PDFDocument from url: \(url)") return } dokumnetpdf = dokument }
Jan ’22
Reply to How does developer migrate apps
Was that helpful, @13774259911?
Replies
Boosts
Views
Activity
Jan ’22
Reply to SwiftUI Preview crashes on simple code
"padding()" should be ".padding()" As in: struct ContentView: View { var body: some View { VStack { Text("Hello, world!") .padding() Text("Another Line") } } } "padding()" is an instance method, so calling it without the leading ".", as you do, probably causes something horrible to happen, which causes the crash. (Since it will return a function, not a View)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Any Mac mini M1 sufficient for RealityKit Object Capture?
Yes, all the M1 Macs support RealityKit Object Capture. From the page you linked to, the requirements are: at least 4 GB of RAM a GPU which supports ray tracing As a double-check, I ran the tests on that page, on my MacBook Pro, which also uses an M1. All tests passed.
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Where is the selection of primary category made?
On App Store Connect, this is in the General section, under "App Information" Then look for General Information > Category
Replies
Boosts
Views
Activity
Jan ’22
Reply to AVAssetDownloadDelegate methods are not called when resumed
On restoring the task, do you need to re-assign it's delegate?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Can I use api `UIApplicationVolumeUpButtonDownNotification` for getting volume up/down button?
AVAudioSession has a property "outputVolume". You could look for changes to this, using Key-value observing... ...and use that to trigger your photo. That might go against rule 2.5.9, but since Apple's Camera app uses the volume buttons, I think it should be okay. (Note: this technique does not work in the Simulator, it needs a real device) Perhaps something like this: import AVFAudio class VolumeButtonObserver { let audioSession = AVAudioSession.sharedInstance() var outputVolumeObservation: NSKeyValueObservation? init() { observeVolumeButtons() } func observeVolumeButtons() { do { try audioSession.setActive(true) } catch {} outputVolumeObservation = audioSession.observe(\.outputVolume) { (audioSession, changes) in print("A volume button was pressed") /// Take action here... } } }
Replies
Boosts
Views
Activity
Jan ’22
Reply to Changing ViewControllers in ViewContainer Messing Up UIDatePicker
It's probably something to do with constraints, or you may be positioning/sizing something in viewDidLoad that needs to be done in viewWillAppear. You might like to share the relevant code from "controller"?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to iMac can’t recognize Logitech keyboard and mouse on login
Yes this seems to be a problem, where certain bluetooth devices are not recognized, before logging in. Which makes it difficult to login! I had a recent trauma with this, when booting in Recovery mode... I had to dig out an ancient wired mouse. I will be interested to see if anyone has a solution to this. iMac Pro MK Anywhere 2 mouse Wired keyboard (to get round this issue!)
Topic: App & System Services SubTopic: Hardware Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Pass a Timer through Controllers
I also wish for the user to be able to close the app and have the timer run in the background The timer will not run in the background, but here is a technique that you could use: Add a mechanism to detect when the app is entering the background, or foreground On backgrounding: If your timer is live... Convert it to a notification (calculate the fire date from the timer expiry) Cancel the timer If the timer expires while the app is backgrounded, the user will see the notification On foregrounding: Remove pending notifications Restart the timer, if it has not expired
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Tab Bar,Navigation bar and split view
Please supply more information. Which platform... macOS, iPadOS, iOS...? Also, why tag with wwdc... is this a language question (Swift, Objective-C), or an Xcode question?
Replies
Boosts
Views
Activity
Jan ’22
Reply to Am getting wrong index path.row from tableview
TableView will not necessarily create all your table rows at once. It will fill the screen... ...then on scrolling down, more table rows are created, as required. Have you tested this behavior? Tip: On the Forum, use "Paste and Match Style" with a code block, to avoid all the blank lines.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to How to get data from [Float] correctly?
Try this: let vertexData: [Float] = [1, 2, 3] var data = Data() vertexData.withUnsafeBytes { data.append(contentsOf: $0) }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Cannot convert value of type 'Int' to expected argument type 'string'
When you say... Text("Duration in Minutes: \(StepperValue)") ...you are converting StepperValue from Int to String. So change: URLQueryItem(name: "PollDuration", value: StepperValue) to: URLQueryItem(name: "PollDuration", value: "\(StepperValue)")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to import pdf from url
PDFDocument(url:) returns an Optional value... Try this: func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let url = urls.first else {         print("Error: no url") return } guard let dokument = PDFDocument(url: url) else { print("Error: could not create PDFDocument from url: \(url)") return } dokumnetpdf = dokument }
Replies
Boosts
Views
Activity
Jan ’22
Reply to import pdf from url
It looks like a permissions issue. Try this: func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let url = urls.first else { print("Error: no url") return } guard url.startAccessingSecurityScopedResource() else { print("Error: could not access content of url: \(url)") return } guard let dokument = PDFDocument(url: url) else { print("Error: could not create PDFDocument from url: \(url)") return } dokumnetpdf = dokument }
Replies
Boosts
Views
Activity
Jan ’22