When I tap and immediately type, the UITextField freezes, but if I tap it then wait, type works

110 Views Asked by At

This is the image if it's freezing when I don't wait after tapping the text field. The text field turns yellow, weird ... : https://i.stack.imgur.com/OLzfo.png

This is an image of the text field working when I do wait after tapping:
https://i.stack.imgur.com/wmrRY.png

Below is the code for the view controller:

import UIKit

class Sign_In_page: UIViewController {
    
    @IBOutlet weak var Forgot_Password_Button: UIButton!
    @IBOutlet weak var Sign_In_Button: UIButton!
    @IBOutlet weak var Create_New_Account_Button: UIButton!
    @IBOutlet weak var Facebook_Connect_Button: UIButton!
    @IBOutlet weak var Google_Connect_Button: UIButton!
    
    @IBOutlet weak var Password_Text_Field: UITextField!
    
    var passwordVisible = true
    
    func resizeImage(image: UIImage, targetSize: CGSize) -> UIImage {
            let size = image.size

            let widthRatio  = targetSize.width  / size.width
            let heightRatio = targetSize.height / size.height

            let newSize = widthRatio > heightRatio ? CGSize(width: size.width * heightRatio, height: size.height * heightRatio) : CGSize(width: size.width * widthRatio,  height: size.height * widthRatio)
            let rect = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)

            UIGraphicsBeginImageContextWithOptions(newSize, false, 1.0)
            image.draw(in: rect)
            let newImage = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()

            return newImage!
        }

    override func viewDidLoad() {
            super.viewDidLoad()
  
            Password_Text_Field.isSecureTextEntry = true

            var configuration = UIButton.Configuration.filled()
            configuration.image = resizeImage(image: UIImage(systemName: "eye.fill")!.withTintColor(.black), targetSize: CGSize(width: 18, height: 18))
            configuration.imagePadding = 0
            configuration.baseBackgroundColor = .clear
            configuration.baseForegroundColor = .black
            configuration.cornerStyle = .medium

        var eyeButton: UIButton? = nil
        eyeButton = UIButton(configuration: configuration, primaryAction: UIAction(handler: { [weak self] _ in
            self?.eyeButtonAction(eyeButton!)
        }))

            Password_Text_Field.rightView = eyeButton
            Password_Text_Field.rightViewMode = .always

            self.view.addSubview(Password_Text_Field)
        }

    @objc func eyeButtonAction(_ sender: UIButton) {
            passwordVisible = !passwordVisible
            var configuration = sender.configuration
            if passwordVisible {
                configuration?.image = resizeImage(image: UIImage(systemName: "eye.slash.fill")!.withTintColor(.black), targetSize: CGSize(width: 18, height: 18))
                Password_Text_Field.isSecureTextEntry = true
            } else {
                configuration?.image = resizeImage(image: UIImage(systemName: "eye.fill")!.withTintColor(.black), targetSize: CGSize(width: 18, height: 18))
                Password_Text_Field.isSecureTextEntry = false
            }
            sender.configuration = configuration
        }

    @IBAction func Email_Text_Field(_ sender: Any) {
    }
    
    
    @IBAction func Forgot_Password_Button_Touched(_ sender: Any) {
    }
    
    @IBAction func Sign_In_Button_Touched(_ sender: Any) {
    }
    
    @IBAction func Create_New_Account_Button_Touched(_ sender: Any) {
    }
    
    
    @IBAction func Facebook_Connect_Button_Touched(_ sender: Any) {
    }
    
    @IBAction func Google_Connect_Button_Touched(_ sender: Any) {
        print("hi")
    }   
}

This is the error that I would get from taping the text field and it just doesnt make sense for it to be the error:

objc[17368]: Class AKAlertImageURLProvider is implemented in both /Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit (0x11e3e5d10) and /Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKitUI.framework/AuthKitUI (0x14b5c2010). One of the two will be used. Which one is undefined.

This is another error but I think this has nothing to do with my problem:

Cannot show Automatic Strong Passwords for app bundleID: OVD.LOCALY-APP due to error: iCloud Keychain is disabled

I also get this, but don't think it's relevant to my problem:

Error for queryMetaDataSync: 2

This text box should just be able to immediately be typed. I shouldn't have to wait for it to work, no async is going on here.

0

There are 0 best solutions below