Post

Replies

Boosts

Views

Activity

Reply to Constraints don't work (UIKit)
before adding a constraint you must set the translatesAutoresizingMaskIntoConstraints=false on the given view. import UIKit class ViewController: UIViewController {     var myView = UIView()     override func viewDidLoad() {         super.viewDidLoad()         myView.frame.size.width = 100         myView.frame.size.height = 100         myView.backgroundColor = .green         view.addSubview(myView)         let margins = view.layoutMarginsGuide /** set translatesAutoresizingMaskIntoConstraints=false for every view a constraint is being applied to*/ myView.translatesAutoresizingMaskIntoConstraints=false          myView.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’22
Reply to Had this error for days now and I can't fix it
The following works without issue. struct ContentView: View {     enum ModelCategory: String, CaseIterable, Identifiable {         case one, two, three, four, five, six         var id: String {             self.rawValue         }     }     var body: some View {         VStack {             ForEach(ModelCategory.allCases, id: \.self) { value in                 Text(value.id)             }         }     } } But because you have introduced a member variable that is not initialized this is the error being raised. If you have a preview snippet, pass the showBrowse param into the ModelsByCategoryGrid(showBrowse: Binding.constant(false)) or give the showBrowse a default value.     @Binding var showBrowse: Bool
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’22
Reply to Initialization order of SwiftUI Application + @UIApplicationDelegateAdaptor
Don't overthink the architecture. You should not be using or depending on didSet. The documentation states then once an application delegate also conforms to the ObservableObject type it is automatically available to the entire SwiftUI Application because it places it into the Environment via the EnvironmentObject on your behalf. So move away from the swift didSet/willSet paradigm for property observations and move toward combine or publishers in the form of making the properties of interest into annotated @Published type. Then anywhere in your swiftUI code that needs access to some kind of data from the app delegate will automatically have it via the following pattern. @EnvironmentObject private var appDelegate: MyAppDelegate Read here: https://developer.apple.com/documentation/swiftui/uiapplicationdelegateadaptor
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’22
Reply to Question about formatting of Measurement<...> items
Please re-add the unreadable code above in the Your Answer box using the code block feature.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to IOUSBHostDevice fails and throws error in sandboxed app
Checkbox USB on App Sandbox under Signing & Capabilities Just realized you have the entitlement on.
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Undocumented 'NSViewActuallyUpdateFromLayoutEngine' call adds width when light/dark mode changes
FIle a bug report https://feedbackassistant.apple.com/welcome with a code example.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Constraints don't work (UIKit)
before adding a constraint you must set the translatesAutoresizingMaskIntoConstraints=false on the given view. import UIKit class ViewController: UIViewController {     var myView = UIView()     override func viewDidLoad() {         super.viewDidLoad()         myView.frame.size.width = 100         myView.frame.size.height = 100         myView.backgroundColor = .green         view.addSubview(myView)         let margins = view.layoutMarginsGuide /** set translatesAutoresizingMaskIntoConstraints=false for every view a constraint is being applied to*/ myView.translatesAutoresizingMaskIntoConstraints=false          myView.trailingAnchor.constraint(equalTo: margins.trailingAnchor).isActive = true     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to SwiftUI List Separator within NavigationView Problem
Now check the view hierarchy and see how many navbar titles and bar items you might have compared to the first example where they're just added once outside of the list. Use Swift Application playgrounds for SwiftUI and not the original playgrounds
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to SwiftUI Video Player
none
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Decoding JSON
See the following Apple brief on Custom types and JSON: https://developer.apple.com/documentation/foundation/archives_and_serialization/using_json_with_custom_types
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Had this error for days now and I can't fix it
The following works without issue. struct ContentView: View {     enum ModelCategory: String, CaseIterable, Identifiable {         case one, two, three, four, five, six         var id: String {             self.rawValue         }     }     var body: some View {         VStack {             ForEach(ModelCategory.allCases, id: \.self) { value in                 Text(value.id)             }         }     } } But because you have introduced a member variable that is not initialized this is the error being raised. If you have a preview snippet, pass the showBrowse param into the ModelsByCategoryGrid(showBrowse: Binding.constant(false)) or give the showBrowse a default value.     @Binding var showBrowse: Bool
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Initialization order of SwiftUI Application + @UIApplicationDelegateAdaptor
Don't overthink the architecture. You should not be using or depending on didSet. The documentation states then once an application delegate also conforms to the ObservableObject type it is automatically available to the entire SwiftUI Application because it places it into the Environment via the EnvironmentObject on your behalf. So move away from the swift didSet/willSet paradigm for property observations and move toward combine or publishers in the form of making the properties of interest into annotated @Published type. Then anywhere in your swiftUI code that needs access to some kind of data from the app delegate will automatically have it via the following pattern. @EnvironmentObject private var appDelegate: MyAppDelegate Read here: https://developer.apple.com/documentation/swiftui/uiapplicationdelegateadaptor
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to How to generate a CSR for a Apple Distibution Cert using windows computer?
Google your question!
Replies
Boosts
Views
Activity
Mar ’22
Reply to TextEditor Keyboard Avoidance not working
Submit a bug report!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Flutter app not opening on Xcode(macOS) although working in Windows for android
Flutter is not an Apple product. All third party framework implementors shoud post all relevant questions to the respective support forums for those frameworks: Please goto https://github.com/flutter
Replies
Boosts
Views
Activity
Mar ’22
Reply to M1 Pro Mac USB Hub and External Hard-drive not Mounting
Wrong forum!
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Enabling/disabling Package Dependencies on build or across schemes?
Just keep a branch for that client with their customizations.
Replies
Boosts
Views
Activity
Mar ’22
Reply to How do I measure/get a heartbeat at thousands of seconds from Apple Watch?
What is the API question?
Replies
Boosts
Views
Activity
Mar ’22