How to know a device is available to use captureTextFromCamera API?
One simple condition:
UITextField().canPerformAction(#selector(UIResponder.captureTextFromCamera(_:))
Tests both device support and language setting support
Check if Apple LiveText is available?
Don't check for the iOS 15+ and processor A12+, check for the iOS 15's 'Live Text'feature support. Create a helper method with the following check that will return whether the device support live text or not
Sample:
var isSupported = true
if #available(iOS 15.0, *) {
let check = UITextField().canPerformAction(#selector(UIResponder.captureTextFromCamera(_:)), withSender: nil)
isSupported = check
} else {
isSupported = false
}
print(isSupported)
Using the above condition will return false
in the case of the device having iOS 15+ but not having hardware support.
How to Remove UIMenuController Default Items In Swift
I tried this but it worked for my by subclassing the WebView and overriding canPerformAction
method, inside which I manually removed the default options.
override func canPerformAction(_ action: Selector, withSender sender: AnyObject?) -> Bool {
if action == #selector(cut(_:)) {
return false
}
if action == #selector(paste(_:)) {
return false
}
if action == #selector(select(_:)) {
return false
}
if action == #selector(selectAll(_:)) {
return false
}
...
return super.canPerformAction(action, withSender: sender)
}
I referred to this answer by Ike10 and it had worked for me. Give it a shot.
Related Topics
How to Run My Performance Tests More Than Ten Times
Swiftui Tabbedview Only Shows First Tab's Content
How to Apply Multiple Masks to Uiview
(Swift Spritekit) Rotate Sprite in the Direction of Touch
Today Extension with Uicollectionview Different Behaviour Compared to Single View Application
Setting Uiimageview Image Affects Layout Constraints
Get the Value of Variable Out of Closure Swift
How to Make a Popup Window with an Image Swift
How to Refresh a Timer in a Today Widget
Custom Sequence for Swift Dictionary
How to Get the Correct Current Time in iOS
Swift - Using Cgcontext to Draw with Finger