Post

Replies

Boosts

Views

Activity

How to modify context menu shown in a UITextView?
In my iPad app running under macOS Catalyst I would like to modify the context menu that appears when you right-click on a UITextViiew but I can't figure out how.I have overridden the buildMenuWithBulder:/buildMenu(with:) method from UIResponder in my view controller and app delegate but none are called when right-clicking on a UITextView.I have been able to disable a couple of the menu options by subclassing UITextView and overriding the canPerformAction:withSender:/canPerformAction(_:withSender:) and targetForAction:withSender:/target(_:withSender:) methods but I can't remove/disable most of the menu.I also overrode the validateCommand:/validate(_:) method in my UITextView subclass and that was only called for a small subset of the menus I wish to remove/disable.The Menus sample app only shows how to modify the app's main menu and how to add a context menu to a view controller but there is no info on how to modify the context menu of a control such as UITextView.Does anyone know how to do this?Specifically I want to remove the Show Fonts and Show Colors menus under Font and I wish to remove the whole Substitutions menu. The allowsEditingTextAttributes property of the text view is enabled which is what makes the Font portion of the menu appear. I want to keep the Bold/Italic/Underline toggles.
2
0
3.6k
Nov ’19
How to get the AVCam demo app to work under Mac Catalyst?
My own iOS app is using AVFoundation to do barcode scanning. Under Mac Catalyst I'm getting an error. Turns out the Apple provided AVCam demo app has the exact same issue.Both the Swift and Objective-C versions of the AVCam demo app fail but the Objective-C version gives a better error so I'll refer to that in the rest of the question.In the AVCamCameraViewController, the configureSession method fails on the line:AVCaptureDeviceInput* videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];The error is:Could not create video device input: Error Domain=AVFoundationErrorDomain Code=-11814 "Cannot Record" UserInfo={NSLocalizedDescription=Cannot Record, NSLocalizedRecoverySuggestion=Try recording again.}It turns out that none of the three attempts to call [AVCaptureDevice defaultDeviceWithDeviceType:... are succeeding.This is the same error I get in my own app though I only attempt to call [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; which is also returning nil.Permission was granted for the app to access the camera.There is nothing related to this issue in the release notes for macOS 10.15. I am running the GM version of 10.15 with Xcode 11.1 on a 2018 15" Macbook Pro.How do we successfully get a video capture device under Mac Catalyst?
5
0
4.3k
Oct ’19
UISceneActivationConditions and UIApplicationShortcutItem
Just watched the Targeting Content with Multiple Windows video. My app uses UIApplicationShortcutItem and UIApplication.shortcutItems.So I thought it would be useful to set the targetContentIdentifier property of each shortcut item so when the user selects one of the shortcuts, they can be brought to the mose appropriate scene in the app.But UIApplicationShortcurItem targetContentIdentifer is a read-only property. Is this is mistake?The documentation for UISceneActiviationConditions states (emphesis mine):Many different objects contain a targetContentIdentifier property, including NSUserActivity, UNNotificationContent, and UIApplicationShortcutItem. When creating those objects, fill that property with a value that uniquely describes the event and matches your scenes' predicates.Kind of hard to do when the property is read-only.Am I missing something or is this an API bug?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
1k
Sep ’19