Swift – Checking file sizes from a server before downloading is causing a lag in the app

I have a server that you can import videos to which when uploaded should downloads directly to the app. The issue is that the app will start downloading the video file before it has been fully uploaded to the server. I set up a timer that runs every 10 seconds which checks the folder for […]

Categories
Development Swift

SwiftUI ZStack reversed positioning order of views using alignmentGuide()

I am trying to display a custom layout using ZStack of a table with a column titles and some rows, but I get a reversed layout to the order I specify in the body. Here is the code: import SwiftUI struct Test: View { var columns : [String] = [“Column 1″,”Column 2”] var cells : […]

SwiftUI DatePicker Binding optional Date, valid nil

I’m experimenting code from https://alanquatermain.me/programming/swiftui/2019-11-15-CoreData-and-bindings/ my goal is to have DatePicker bind to Binding< Date? > which allow for nil value instead of initiate to Date(); this is useful, if you have Date attribute in your core data model entity which accept nil as valid value. Here is my swift playground code: extension Binding { […]

Categories
Development Swift

How to make the overlap area of navigationBarTitle and navigationBarItem tappable – SwiftUI

Currently only the middle part of the red area is tappable, and I know the below area is overlapping with navigationBarTitle, but I still wonder if it is feasible to make the below area to be tappable as well. import SwiftUI struct ContentView: View { @ObservedObject var taskStore: TaskStore @State var modalIsPresented = false var […]

Categories
Development Swift

How do I change the metadata of audio files in Swift?

So far, I’ve extracted thing such as the name of the song, album name, artist name, album art, etc. for use in displaying the now playing song. Now I want to add in the capability to rename the songs from within the app and actually change the metadata of the audio file so the rename […]

RxSwift: Pass actual observable to another view controller?

I have a view controller that needs to know about a boolean variable headerCollapsed that is set from another view controller. In vc1 I have: headerCollapsed = ReplaySubject<Bool>.create(bufferSize: 1) collapsedObservable = headerCollapsed.asObservable() and a function that sets the boolean to true: func updateHeader self.headerCollapsed.onNext(true) end Then, to avoid creating further dependencies and calling vc1 directly, […]

Categories
Development Swift

How to change camera position by dragging finger on the screen – Swift

I’m trying to learn ARKIT and make a small demo app to draw in 3D. The following is the code I wrote and so far there are no problems: import UIKit import ARKit class ViewController: UIViewController, ARSCNViewDelegate { @IBOutlet weak var sceneView: ARSCNView! @IBOutlet weak var DRAW: UIButton! @IBOutlet weak var DEL: UIButton! let config […]

How to animate/transition text value change in SwiftUI

I am trying to animate value change in a text using withAnimation but it doesn’t seem to work. I have come across a similar question but the answer is not animating the text value. I am trying to recreate this behaviour in pure SwiftUI (UIKit Example): I have tried this code but it doesn’t animate […]

Get X-WP-Total headers with Swift

In WordPress REST API Hanbdook is written what: To determine how many pages of data are available, the API returns two header fields with every paginated response: X-WP-Total: the total number of records in the collection X-WP-TotalPages: the total number of pages encompassing all available records https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/#pagination-parameters How I can get this data with Swift?

SwiftUI Alert Showing Duplicate Buttons and Not Triggering Action

For some reason, the following code is displaying an Alert with three instances of the same button, none of which trigger the action as expected: Has anyone else experienced this? Any suggestions on a fix? It’s building on Xcode 11.2.1, for an iOS 13.0 target, then running on macOS via Catalyst (10.15.1). public struct ContactUsView: […]