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.
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
- Swift - Snapshotting a view that has not been rend
Kudos to @GxocT for the the great workaround! Helped my users immensely.
But I wanted to share my code based on @GxocT solution hoping it will help others in this scenario.
I needed my
CNContactViewControllerDelegate
contactViewController(_:didCompleteWith:)
to be called on cancel (as well as done).Also my code was not in a
UIViewController
so there is noself.navigationController
I also dont like using force unwraps when I can help it. I have been bitten in the past so I chained
if let
s in the setupHere's what I did:
Extend
CNContactViewController
and place the swizzle function inthere.
In my case in the swizzle function just call the
CNContactViewControllerDelegate
delegatecontactViewController(_:didCompleteWith:)
withself
andself.contact
object from the contact controllerIn the setup code, make sure the swizzleMethod call to
class_getInstanceMethod
specifies theCNContactViewController
class instead ofself
And the Swift code:
The keyboard still shows momentarily but drops just after the Contacts controller dismisses.
Lets hope apple fixes this
The user can in fact swipe down to dismiss the keyboard and then tap Cancel and see the action sheet. So this issue is regrettable and definitely a bug (and I have filed a bug report) but not fatal (though, to be sure, the workaround is not trivial for the user to discover).
I couldn't find a way to dismiss keyboard. But at least you can pop ViewController using my method.
PS: You can find additional info on reddit topic: https://www.reddit.com/r/swift/comments/dc9n3a/bug_with_cnviewcontroller_ios_131/