Post

Replies

Boosts

Views

Activity

Reply to Why is superview returning nil?
See the Apple document excerpt below. If calling animation didMove(toParent:) is called after the transition not inside of the animation block, no animation the immediately after the addChild. With animation @objc func buttonAction(sender: UIButton!) { guard let theButton = sender as? MyButton else { return} UIView.transition(with: self.view, duration: 0.5, options: .transitionCurlDown, animations: { [self] in self.addChild(setController) self.view.addSubview(setController.view) }, completion: { setController.didMove(toParent: self) }) } No animation @objc func buttonAction(sender: UIButton!) { guard let theButton = sender as? MyButton else { return} self.view.addSubview(setController.view) self.addChild(setController) setController.didMove(toParent: self) } Discussion Your view controller can override this method when it wants to react to being added to a container. If you are implementing your own container view controller, it must call the didMove(toParent:) method of the child view controller after the transition to the new controller is complete or, if there is no transition, immediately after calling the addChild(_:) method. The removeFromParent() method automatically calls the didMove(toParent:) method of the child view controller after it removes the child. Sundel: https://www.swiftbysundell.com/basics/child-view-controllers/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Taking user input in MapKit
Your solution can be the extra work. Google, search GitHub or reach the Apple Documentation, look at the sample code. Begin the base knowledge here: https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW1 Converting MKView touch to coordinates: https://gist.github.com/a1phanumeric/2249553
Dec ’21
Reply to How to know the active & foreground scene in multi-windows supported iPadOS app?
Traverse the scene hierarchy for an active or main window something like below. Might need tweaking. extension UIWindow { public static var keyWindow: UIWindow ? { if #available(iOS 13.0, *) { return UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } .first?.windows.filter { $0.isKeyWindow }.first } else { return UIApplication.shared.keyWindow } } }
Topic: App & System Services SubTopic: Hardware Tags:
Nov ’21
Reply to iOS15 NavigationView lost the state after putting app in background and bring it back
Move the parent NavigationView from LocalNotificationDemoView to the MainView tabs. There is no need for the .navigationViewStyle(.stack) modifier. struct LocalNotificationDemoView: View {     var body: some View {         VStack {             MainView()         }     } } struct MainView: View {     var body: some View {         TabView {             NavigationView {                 Tab1()             } .tabItem {                 Text("Tab1")             }             NavigationView {                 Tab2()             }.tabItem {                 Text("Tab2")             }         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to Why is superview returning nil?
See the Apple document excerpt below. If calling animation didMove(toParent:) is called after the transition not inside of the animation block, no animation the immediately after the addChild. With animation @objc func buttonAction(sender: UIButton!) { guard let theButton = sender as? MyButton else { return} UIView.transition(with: self.view, duration: 0.5, options: .transitionCurlDown, animations: { [self] in self.addChild(setController) self.view.addSubview(setController.view) }, completion: { setController.didMove(toParent: self) }) } No animation @objc func buttonAction(sender: UIButton!) { guard let theButton = sender as? MyButton else { return} self.view.addSubview(setController.view) self.addChild(setController) setController.didMove(toParent: self) } Discussion Your view controller can override this method when it wants to react to being added to a container. If you are implementing your own container view controller, it must call the didMove(toParent:) method of the child view controller after the transition to the new controller is complete or, if there is no transition, immediately after calling the addChild(_:) method. The removeFromParent() method automatically calls the didMove(toParent:) method of the child view controller after it removes the child. Sundel: https://www.swiftbysundell.com/basics/child-view-controllers/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to iOS Simulator Download
Please upgrade to Xcode 13.1 via the mac AppStore
Replies
Boosts
Views
Activity
Dec ’21
Reply to My MapView crashes when I start filling out the address form
The crash log from Xcode is more important.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Taking user input in MapKit
Your solution can be the extra work. Google, search GitHub or reach the Apple Documentation, look at the sample code. Begin the base knowledge here: https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW1 Converting MKView touch to coordinates: https://gist.github.com/a1phanumeric/2249553
Replies
Boosts
Views
Activity
Dec ’21
Reply to polygon count vs. triangle count?
Triangles are used internally to construct polygons and your polygons shouldn't go past 4 sides and if they do then you should try to break into down into a smaller polygon.
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Rating limitations
Please read the API documentation - Apple controls this algorithm.
Replies
Boosts
Views
Activity
Nov ’21
Reply to Can user with older version of iOS buy an app that supports only newer versions?
No. There is no magic, You will have to code & provide support for lower APIs.
Replies
Boosts
Views
Activity
Nov ’21
Reply to How to keep a sidebar item selected when navigation link is triggered in the detail view on iPadOS with SwiftUI?
You need to store the row selected in a state variable. See the Fruta sample code for SmoothieList. @State private var selection: String? ... NavigationLink(tag: some_kind_value_to_tag_each_nav_link_from_list, selection: $selection) ...
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to How to copy screenshots from xcode test suite
Take a look at XCTAttachment documentation.
Replies
Boosts
Views
Activity
Nov ’21
Reply to How to know the active & foreground scene in multi-windows supported iPadOS app?
Traverse the scene hierarchy for an active or main window something like below. Might need tweaking. extension UIWindow { public static var keyWindow: UIWindow ? { if #available(iOS 13.0, *) { return UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } .first?.windows.filter { $0.isKeyWindow }.first } else { return UIApplication.shared.keyWindow } } }
Topic: App & System Services SubTopic: Hardware Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Auto-hide an iOS app following a user action
Listen to your vendor it's why they were hired to do the job.
Replies
Boosts
Views
Activity
Nov ’21
Reply to Double initialized as Decimal returns number with trailing fractional digits
Hence the reason for visual formatters. Don't use the Decimal type unless you really need to. var x:Double = 0.94 var result = "" print(x, terminator: "", to: &result) print(result) // 0.94
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Double initialized as Decimal returns number with trailing fractional digits
Hence the reason for visual formatters. Don't the Decimal type unless you really need to.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to I want to delete the RPScreenRecorder-startCapture confirmation message.
Apple's Privacy mandate & transparency.
Topic: Media Technologies SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to iOS15 NavigationView lost the state after putting app in background and bring it back
Move the parent NavigationView from LocalNotificationDemoView to the MainView tabs. There is no need for the .navigationViewStyle(.stack) modifier. struct LocalNotificationDemoView: View {     var body: some View {         VStack {             MainView()         }     } } struct MainView: View {     var body: some View {         TabView {             NavigationView {                 Tab1()             } .tabItem {                 Text("Tab1")             }             NavigationView {                 Tab2()             }.tabItem {                 Text("Tab2")             }         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21