Post not yet marked as solved
I am having the same problem. Looks like I'm completely hosed, since I updated my Mac to Sonoma, I can't run Xcode 14 to fix the problem!
Post not yet marked as solved
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.
}
}
Post not yet marked as solved
OOOps! I misspoke again.
I use the same line of code in appDelegate. However, obviously, there's no scene in appDelegate.
How can I handle this?
Thanks a lot for the help.
Post not yet marked as solved
Thanks a lot, Claude.
Just what I needed.
Post not yet marked as solved
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.
Post not yet marked as solved
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.
Post not yet marked as solved
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
Post not yet marked as solved
I filed a report on this on 9/14/22. Haven't heard anything since. Does anybody know what the normal response time is?
Thanks.
I did tried AnyView but the secondary extension was what was needed.
OK, thank you. I apreacite the information.
Hi OOPer,This is very close. However, there are 2 things I'd would like to address.As it is the code allows to enter a string of zeros. 00000000000Also, it does not allow for the user to delete all of the characters and leave he filed empty.I added a clear button while editing but won't the user expect to be able to delete all the characters?Thnaks,Tom
Thanks you for the reply. I this case the user knows they are typing in a % value. So wouldn't they be expecting to need to enter a value from 1 to 100?
Thanks PBK,I tried at least 6 ways of doing this but this was the only one the worked.I had to figure out a little more about NotificationCenter than I originally knew but I got it working.Even figured out how to pass data to the parrent VC in the Notification// In parrent
static let notificationName = Notification.Name("ClosingChild")
override func viewDidLoad()
{
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(returnFromPopup), name: Tally_VC.notificationName, object: nil)
}// End of viewDidLoad
@objc func returnFromPopup(notification: Notification)
{
if let data = notification.userInfo?["data"] as? Bool
{
if data
{
self.populateTheData()
self.tableView.reloadData()
} else {
//print("It didn't run")
}
}
}
// In child
var pass_Popup: Bool = false
override func viewDidDisappear(_ animated: Bool)
{
super.viewDidDisappear(animated)
setThe_Pass_Bool()
NotificationCenter.default.post(name: Tally_VC.notificationName, object: nil, userInfo: ["data": pass_Popup])
}
Hi Claude,Thanks you for checking into this.I also tested the app on my iPhone XS MAX and my iPhone 6s and you are correct. It does work as expected on the physical devices. I apologize for not following through on testing on the device. I guess I just got wrapped around the axle when it didn't work on the sim.I'm in the final stages of finishing a series of 8 apps and this through a monkey wrench into the works.I do not have an iPad to test on. I'll try to find someone with an iPad to test it. Until then I'm not comfortable releasing any apps using this code.Thank you,Tom
Post not yet marked as solved
Thanks, I'll try using the attributedPlaceholder.