I have a button inside a custom tableview cell in a tableview. I tried presenting, pushing and instantiating to another view controller but failed by showing error:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional
Here s my code: console image if required
class ProfileHeaderView: UITableViewCell{
@IBAction func editProfile(_ sender: Any) {
let editProfilePage = EditProfileViewController()
UIApplication.shared.keyWindow?.rootViewController?.present(editProfilePage, animated: true, completion: nil)
}
}
The page which i wanted to move:
class EditProfileViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.hideKeyboardWhenTappedAround()
mobileNumber.keyboardType = UIKeyboardType.numberPad **//Error**
}
}
I tried presenting by rootViewController
also. Please help.