CNContactViewController上的iOS 13.1中的键盘覆盖操作表 [英] Keyboard overlaying action sheet in iOS 13.1 on CNContactViewController
问题描述
这似乎特定于iOS 13.1,因为它可以在iOS 13.0和更早版本上按预期工作,可以在CNContactViewController中添加联系人,如果我取消",操作表会被键盘重叠.没有执行任何操作,也没有关闭键盘.
This seems to be specific to iOS 13.1, as it works as expected on iOS 13.0 and earlier versions to add a contact in CNContactViewController, if I 'Cancel', the action sheet is overlapping by keyboard. No actions getting performed and keyboard is not dismissing.
推荐答案
我找不到解散键盘的方法.但是至少您可以使用我的方法弹出ViewController.
I couldn't find a way to dismiss keyboard. But at least you can pop ViewController using my method.
- 不知道为什么,但是无法在CNContactViewController中关闭键盘.我尝试了endEditing :,创建新的UITextField firstResponder,依此类推.什么都没用.
- 我尝试更改取消"按钮的操作.您可以在NavigationController堆栈中找到此按钮,但是每次输入内容时,它的动作都会更改.
- 最后,我使用了方法.如前所述,我找不到关闭键盘的方法,但是至少当按下取消"按钮时,您可以关闭CNContactViewController.
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
changeImplementation()
}
@IBAction func userPressedButton(_ sender: Any) {
let controller = CNContactViewController(forNewContact: nil)
controller.delegate = self
navigationController?.pushViewController(controller, animated: true)
}
@objc func popController() {
self.navigationController?.popViewController(animated: true)
}
func changeImplementation() {
let originalSelector = Selector("editCancel:")
let swizzledSelector = #selector(self.popController)
if let originalMethod = class_getInstanceMethod(object_getClass(CNContactViewController()), originalSelector),
let swizzledMethod = class_getInstanceMethod(object_getClass(CNContactViewController()), swizzledSelector) {
method_exchangeImplementations(originalMethod, swizzledMethod)
}
}
}
PS:您可以找到有关reddit主题的其他信息: https://www.reddit.com/r/swift/comments/dc9n3a/bug_with_cnviewcontroller_ios_131/
PS: You can find additional info on reddit topic: https://www.reddit.com/r/swift/comments/dc9n3a/bug_with_cnviewcontroller_ios_131/
这篇关于CNContactViewController上的iOS 13.1中的键盘覆盖操作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!