One more slight step forward. I have found a way to make the "Take Photo", "Scan Documents", and "Add Sketch" menus do nothing. It's still a poor user experience having the menus at all, but at least now the user doesn't get to go through all of the motions of taking a photo or scanning a document with their iOS device just to have the results ignored.
I was able to make this happen by adding the following code:
@objc func importFromDevice(_ sender: Any) {
// no-op
}
override func target(forAction action: Selector, withSender sender: Any?) -> Any? {
if action == #selector(importFromDevice) {
return self
}
return super.target(forAction: action, withSender: sender)
}
You can add this to a custom UITextView subclass or to the view controller class containing a text view.
The only issue with this code is that it results in assertion failures and big old stack traces in the console each time the menu gets validated. There's a message about:
-[UINSResponderProxy validateMenuItem:]: We're being asked to validate a menu item whose proxy isn't the one we wrapped.
But I've tested via TestFlight and the app continues to run just fine.
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: