I want to traverse through the view hierarch of the MFMessageComposerController so that I can get the instance of UITextField where the messages are populated . Here is the code which I did in Swift for presenting MFMessageController . How can I traverse through its hierarchy?
The code :
@IBAction func sendSmsClick(_ sender: AnyObject) {
guard MFMessageComposeViewController.canSendText() else {
return
}
let messageVC = MFMessageComposeViewController()
messageVC.view.endEditing(true)
messageVC.body = "Enter a message";
messageVC.recipients = ["Enter tel-nr"]
messageVC.messageComposeDelegate = self;
NSLog("Subviews %@", messageVC.view.subviews);
// self.view.endEditing(true)
self.present(messageVC, animated: false) {
}
}
func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
switch (result.rawValue) {
case MessageComposeResult.cancelled.rawValue:
print("Message was cancelled")
self.dismiss(animated: true, completion: nil)
case MessageComposeResult.failed.rawValue:
print("Message failed")
self.dismiss(animated: true, completion: nil)
case MessageComposeResult.sent.rawValue:
print("Message was sent")
self.dismiss(animated: true, completion: nil)
default:
break;
}
}
Can anyone tell how to traverse through the view hierarchy of the MFMessageViewController?
The result of the NSLOG
The agenda of me is to mimic the same as shown in this app. To find the textfield and to Disable the editing . The app from Appstore: