Post

Replies

Boosts

Views

Activity

UIApplicationDelegateAdaptor won't do anything
I just created a SwiftUI project in Xcode 12.5 (12E262) and changed my main App class to import SwiftUI class AppDelegate: UIResponder, UIApplicationDelegate { func applicationDidFinishLaunching(_ application: UIApplication) { print("applicationDidFinishLaunching") } func applicationDidBecomeActive(_ application: UIApplication) { print("applicationDidBecomeActive") } func applicationDidEnterBackground(_ application: UIApplication) { print("applicationDidEnterBackground") } func applicationWillEnterForeground(_ application: UIApplication) { print("applicationWillEnterForeground") } func applicationWillTerminate(_ application: UIApplication) { print("applicationWillTerminate") } } @main struct SwiftUIAppDelegateTestsApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate     var body: some Scene {         WindowGroup {             ContentView()         }     } } No app delegate method is called. Should the App Delegate listed anywhere else e.g. in the build settings or info plist?
2
0
3.6k
Jul ’21
Dismissing a sheet leads to broken button
The code below renders a view with a navigation bar. A plus button is placed on the navigation bar which opens a sheet. After closing this sheet view programmatically the plus button of the first view won't react anymore. Is this an iOS bug or is the code incorrect?import SwiftUI struct ContentView: View { @State var isAddPresented = false var body: some View { NavigationView { Text("Tap plus to add item") .navigationBarTitle("Main Screen Title") .navigationBarItems(trailing: Button(action: { self.isAddPresented = true }) { Image(systemName: "plus") } ) .sheet(isPresented: $isAddPresented, onDismiss: { self.isAddPresented = false }) { NavigationView { Text("Tap on save") .navigationBarTitle("Add something") .navigationBarItems(leading: Button(action: {self.isAddPresented = false}, label: {Text("Save")})) } } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
11
3
7.3k
Sep ’22
HEIC Image generation broken for iOS 17.5 simulator?
This code to write UIImage data as heic works in iOS simulator with iOS < 17.5 import AVFoundation import UIKit extension UIImage { public var heic: Data? { heic() } public func heic(compressionQuality: CGFloat = 1) -> Data? { let mutableData = NSMutableData() guard let destination = CGImageDestinationCreateWithData(mutableData, AVFileType.heic as CFString, 1, nil), let cgImage = cgImage else { return nil } let options: NSDictionary = [ kCGImageDestinationLossyCompressionQuality: compressionQuality, kCGImagePropertyOrientation: cgImageOrientation.rawValue, ] CGImageDestinationAddImage(destination, cgImage, options) guard CGImageDestinationFinalize(destination) else { return nil } return mutableData as Data } public var isHeicSupported: Bool { (CGImageDestinationCopyTypeIdentifiers() as! [String]).contains("public.heic") } var cgImageOrientation: CGImagePropertyOrientation { .init(imageOrientation) } } extension CGImagePropertyOrientation { init(_ uiOrientation: UIImage.Orientation) { switch uiOrientation { case .up: self = .up case .upMirrored: self = .upMirrored case .down: self = .down case .downMirrored: self = .downMirrored case .left: self = .left case .leftMirrored: self = .leftMirrored case .right: self = .right case .rightMirrored: self = .rightMirrored @unknown default: fatalError() } } } But with iOS 17.5 simulator it seems to be broken. The call of CGImageDestinationFinalize writes this error into the console: writeImageAtIndex:962: *** CMPhotoCompressionSessionAddImage: err = kCMPhotoError_UnsupportedOperation [-16994] (codec: 'hvc1') On physical devices it still seems to work. Is there any known workaround for the iOS simulator?
1
1
884
May ’24
Choosing the best framework for a vector image app. SwiftUI, UIKit or CoreGraphics?
I'm wondering which way I should go in my current app project. It is an app where the user can take a photo and place multiple 2D vector images on that photo. Some vector images are showing angles between lines. The user can interact with the vectors to change the angels to make some measurements on the photo. So you have multiple layers of vector images upon a photo. You can also pinch to zoom to have better control to set accurate vectors/angles. The user can choose the layer to interact with so I need to have control of all gesture recognizers and for example deactivate the pinch gestures on the scroll view. I'm wondering which technology I should use 🤔 SwiftUI, UIKit or CoreGraphics? Does somebody have some recommendations?
2
0
1.3k
Jan ’22
UIApplicationDelegateAdaptor won't do anything
I just created a SwiftUI project in Xcode 12.5 (12E262) and changed my main App class to import SwiftUI class AppDelegate: UIResponder, UIApplicationDelegate { func applicationDidFinishLaunching(_ application: UIApplication) { print("applicationDidFinishLaunching") } func applicationDidBecomeActive(_ application: UIApplication) { print("applicationDidBecomeActive") } func applicationDidEnterBackground(_ application: UIApplication) { print("applicationDidEnterBackground") } func applicationWillEnterForeground(_ application: UIApplication) { print("applicationWillEnterForeground") } func applicationWillTerminate(_ application: UIApplication) { print("applicationWillTerminate") } } @main struct SwiftUIAppDelegateTestsApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate     var body: some Scene {         WindowGroup {             ContentView()         }     } } No app delegate method is called. Should the App Delegate listed anywhere else e.g. in the build settings or info plist?
Replies
2
Boosts
0
Views
3.6k
Activity
Jul ’21
Dismissing a sheet leads to broken button
The code below renders a view with a navigation bar. A plus button is placed on the navigation bar which opens a sheet. After closing this sheet view programmatically the plus button of the first view won't react anymore. Is this an iOS bug or is the code incorrect?import SwiftUI struct ContentView: View { @State var isAddPresented = false var body: some View { NavigationView { Text("Tap plus to add item") .navigationBarTitle("Main Screen Title") .navigationBarItems(trailing: Button(action: { self.isAddPresented = true }) { Image(systemName: "plus") } ) .sheet(isPresented: $isAddPresented, onDismiss: { self.isAddPresented = false }) { NavigationView { Text("Tap on save") .navigationBarTitle("Add something") .navigationBarItems(leading: Button(action: {self.isAddPresented = false}, label: {Text("Save")})) } } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
Replies
11
Boosts
3
Views
7.3k
Activity
Sep ’22
HEIC Image generation broken for iOS 17.5 simulator?
This code to write UIImage data as heic works in iOS simulator with iOS < 17.5 import AVFoundation import UIKit extension UIImage { public var heic: Data? { heic() } public func heic(compressionQuality: CGFloat = 1) -> Data? { let mutableData = NSMutableData() guard let destination = CGImageDestinationCreateWithData(mutableData, AVFileType.heic as CFString, 1, nil), let cgImage = cgImage else { return nil } let options: NSDictionary = [ kCGImageDestinationLossyCompressionQuality: compressionQuality, kCGImagePropertyOrientation: cgImageOrientation.rawValue, ] CGImageDestinationAddImage(destination, cgImage, options) guard CGImageDestinationFinalize(destination) else { return nil } return mutableData as Data } public var isHeicSupported: Bool { (CGImageDestinationCopyTypeIdentifiers() as! [String]).contains("public.heic") } var cgImageOrientation: CGImagePropertyOrientation { .init(imageOrientation) } } extension CGImagePropertyOrientation { init(_ uiOrientation: UIImage.Orientation) { switch uiOrientation { case .up: self = .up case .upMirrored: self = .upMirrored case .down: self = .down case .downMirrored: self = .downMirrored case .left: self = .left case .leftMirrored: self = .leftMirrored case .right: self = .right case .rightMirrored: self = .rightMirrored @unknown default: fatalError() } } } But with iOS 17.5 simulator it seems to be broken. The call of CGImageDestinationFinalize writes this error into the console: writeImageAtIndex:962: *** CMPhotoCompressionSessionAddImage: err = kCMPhotoError_UnsupportedOperation [-16994] (codec: 'hvc1') On physical devices it still seems to work. Is there any known workaround for the iOS simulator?
Replies
1
Boosts
1
Views
884
Activity
May ’24
Choosing the best framework for a vector image app. SwiftUI, UIKit or CoreGraphics?
I'm wondering which way I should go in my current app project. It is an app where the user can take a photo and place multiple 2D vector images on that photo. Some vector images are showing angles between lines. The user can interact with the vectors to change the angels to make some measurements on the photo. So you have multiple layers of vector images upon a photo. You can also pinch to zoom to have better control to set accurate vectors/angles. The user can choose the layer to interact with so I need to have control of all gesture recognizers and for example deactivate the pinch gestures on the scroll view. I'm wondering which technology I should use 🤔 SwiftUI, UIKit or CoreGraphics? Does somebody have some recommendations?
Replies
2
Boosts
0
Views
1.3k
Activity
Jan ’22