I want to disable my back button while the user has the keyboard engaged.Here's what I have so far:The "backButton.isEnabled = false" disables the back button perfectly in "viewDidLoad":class DetailViewController: UIViewController, UITextViewDelegate {
var backButton = UIBarButtonItem()
override func viewDidLoad() {
super.viewDidLoad()
backButton.title = "Save"
backButton.isEnabled = false
self.navigationController?.navigationBar.topItem?.backBarButtonItem = backButtonThe below code works to trigger "keyboard is here" and "keyboard is gone" when the keyboard is called/dismissed: override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
{
@objc func keyboardWillShow(notification: Notification) {
print("keyboard is here")
}
@objc func keyboardWillHide(notification: Notification) {
print("keyboard is gone")
}However, when I try to drop the "backButton.isEnabled = false" in the "@objc func keyboardWillShow" function, nothing happens. @objc func keyboardWillShow(notification: Notification) {
print("keyboard is here")
backButton.isEnabled = false
}Not sure why the "backButton.isEnabled = false" works in the viewDidLoad but not keyboardWillShow... Any idea how to fix this?
Post
Replies
Boosts
Views
Activity
I had a working Splash Screen but needed to add a "Loading Screen" to follow the Splash Screen because I plan to use some animation while the app loads. Since I added the Loading Screen, the Splash Screen no longer displays the Splash Image (screen is all black) until the Loading Screen appears on the iOS simulator. Any thoughts?
Interface Builder Document is as follows on the Splash Screen:
Opens in: Latest Xcode (12.0)
Builds for: Deployment Target (13.0)
Use Trait Variations (checked)
Use Safe Area Layout Guides (checked)
Use as Launch Screen (checked)
I've tried the following fixes based on what I found online, without success:
1) Deleting Derived Data (seemed to work once, but then not after that);
2) Erasing all content and settings from Simulator;
3) "General" > App Icons and Launch Images > Launch Screen File is set to "LaunchScreen" (my Splash Screen is titled "LaunchScreen.storyboard");
4) I deleted/reinstalled the app
Any thoughts on why it won't display my Splash Screen?