Post

Replies

Boosts

Views

Activity

Reply to .main is going to be deprecated
Claude, Here's the code from my appDelegate. import UIKit var gScreenSize = CGRect() var gScreenHeight: CGFloat = 0.0 var gScreenWidth: CGFloat = 0.0 var gOrientation: String = "" @main class AppDelegate: UIResponder, UIApplicationDelegate {     var window: UIWindow?     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {         // Override point for customization after application launch.         NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)         return true     }     @objc func rotated()     {         let theCurrentDevice = UIDevice.current                  if theCurrentDevice.orientation.isValidInterfaceOrientation         {             let deviceOrientationRaw = theCurrentDevice.orientation.rawValue             switch deviceOrientationRaw             {             case 1: // Home Button at the Bottom                 gScreenSize = UIScreen.main.fixedCoordinateSpace.bounds                                  let firstScene = window?.windowScene                 if let w = firstScene                 {                     // gScreenSize = w.screen.bounds                     print("portrait bottom", w.screen.bounds)                 }                  print("Portrait AppDelegate height", gScreenSize.height)                  print("Portrait AppDelegate width", gScreenSize.width)                                gOrientation = "Portrait" // K.Oreientation.portrait                 gScreenHeight = gScreenSize.height                 gScreenWidth = gScreenSize.width                              case 2: // Home Button at the Top                 gScreenSize = UIScreen.main.fixedCoordinateSpace.bounds                                  let firstScene = window?.windowScene                 if let w = firstScene                 {                     // gScreenSize = w.screen.bounds                     print("portrait top", w.screen.bounds)                 }                                   print("Portrait AppDelegate height", gScreenSize.height)                  print("Portrait AppDelegate width", gScreenSize.width)                                  gOrientation = "Portrait" // K.Oreientation.portrait                 gScreenHeight = gScreenSize.height                 gScreenWidth = gScreenSize.width                              case 3: // Home Button on the Right                 gScreenSize = UIScreen.main.fixedCoordinateSpace.bounds                                  let firstScene = window?.windowScene                 if let w = firstScene                 {                     // gScreenSize = w.screen.bounds                     print("Landscape right", w.screen.bounds)                 }                                   print("Landscape Home Right AppDelegate height", gScreenSize.width)                  print("Landscape Home Right AppDelegate width", gScreenSize.height)                                  gOrientation = "Landscape" // K.Oreientation.landscape                 gScreenHeight = gScreenSize.width                 gScreenWidth = gScreenSize.height                              case 4: // Home Button on the Left                 gScreenSize = UIScreen.main.fixedCoordinateSpace.bounds                                  let firstScene = window?.windowScene                 if let w = firstScene                 {                     // gScreenSize = w.screen.bounds                     print("Landscape left", w.screen.bounds)                 }                                   print("Landscape Home Left AppDelegate height", gScreenSize.width)                  print("Landscape Home Left AppDelegate width", gScreenSize.height)                                  gOrientation = "Landscape" // K.Oreientation.landscape                 gScreenHeight = gScreenSize.width                 gScreenWidth = gScreenSize.height                              case 5:                 //deviceOrreientation = "Face Up"                 break                              case 6:                 //deviceOrreientation = "Face Down"                 break                              default:                 // gOrientation_2 = K.Oreientation.unknown                 break             }         }     }     // MARK: UISceneSession Lifecycle     func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {         // Called when a new scene session is being created.         // Use this method to select a configuration to create the new scene with.         return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)     }     func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {         // Called when the user discards a scene session.         // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.         // Use this method to release any resources that were specific to the discarded scenes, as they will not return.     } }
Dec ’22
Reply to .main is going to be deprecated
I apologize for misspeaking. I don't get a true warning. When I type .main the auto select box shows the "alert". I am also running Xcode 14.2. I'm just trying to be proactive and fix this before it gets broken in the future and I'm currently updating this app. Typing view.window.windowScene.screen in the sceneDelegate shows a warning though.
Dec ’22
Reply to Setting up keyboard avoidance to a textview using keyboardLayoutGuide
I really appreciate your willingness to help with my dilemma. I'v been beating on this for more than a weeks time. I couldn't get the code snippets you shared to work properly. What would really help is if you can find the time to put together a demo app using IB that works and then share that code. I realize that's a lot to ask but it would probably help a ton of there developers too. Objectives: Use IB for the Layout. Use keyboardLayoutGuide.followsUndockedKeyboard. Allow for floating keyboard on iPad. Move the textView up to clear the keyboard when it's tapped. Move the textView to home position when the keyboard is hidden or when the textView is not firstResponder (When the textField is tapped). Hide the keyboard when the view is tapped. If textview is first responder when the keyboard is changed to floating, move the textView to nome position. On iPad, when the device is rotated and the textView is firstResponder, have the keyboard hug the top of the textview.
Oct ’22
Reply to The firing order of NotificationCenter observing when the keyboard appears and textViewDidBeginEditing has been changed.
Following more testing it seems the firing order is changing with each iOS release. Can somebody please verify this? iOS 15.5 keyboardWillShow textViewDidBeginEditing iOS 15.6.1 textViewDidBeginEditing keyboardWillShow iOS 15.7 keyboardWillShow textViewDidBeginEditing iOS 16 - in the sim because I'm reluctant to update to 16 on my devices. textViewDidBeginEditing keyboardWillShow
Oct ’22