-
Adopt desktop-class editing interactions
Discover advanced desktop-class editing features that can help people accelerate their productivity in your app. Learn how you can provide more interactions inline with your UI to help people quickly access editing features and make your iPadOS app feel right at home on macOS with Mac Catalyst. We'll also explore the highly-customizable find interaction and learn how the system UI can help people consistently find content in your app.
Recursos
- UIFindInteraction
- UIEditMenuInteraction
- Building a desktop-class iPad app
- Supporting desktop-class features in your iPad app
Videos relacionados
WWDC22
WWDC19
-
Buscar este video…
-
-
2:42 - Adding items into text edit menus
func textView( _ textView: UITextView, editMenuForTextIn range: NSRange, suggestedActions: [UIMenuElement]) -> UIMenu? -
4:03 - Adding actions into a text view's menu
func textView( _ textView: UITextView, editMenuForTextIn range: NSRange, suggestedActions: [UIMenuElement] ) -> UIMenu? { var additionalActions: [UIMenuElement] = [] if range.length > 0 { let highlightAction = UIAction(title: "Highlight", ...) additionalActions.append(highlightAction) } let insertPhotoAction = UIAction(title: "Insert Photo", ...) additionalActions.append(insertPhotoAction) return UIMenu(children: suggestedActions + additionalActions) } -
5:24 - Presenting an edit menu with a custom gesture
let editMenuInteraction = UIEditMenuInteraction(delegate: self) view.addInteraction(editMenuInteraction) let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTap(_:))) tapRecognizer.allowedTouchTypes = [UITouch.TouchType.direct.rawValue as NSNumber] view.addGestureRecognizer(tapRecognizer) @objc func didTap(_ recognizer: UITapGestureRecognizer) { let location = recognizer.location(in: self.view) if self.hasSelectedObjectView(at: location) { let configuration = UIEditMenuConfiguration(identifier: nil, sourcePoint: location) editMenuInteraction.presentEditMenu(with: configuration) } } -
7:13 - Implementing UIEditMenuInteractionDelegate
func editMenuInteraction( _ interaction: UIEditMenuInteraction, targetRectFor configuration: UIEditMenuConfiguration ) -> CGRect { guard let selectedView = objectView(at: configuration.sourcePoint) else { return .null } return selectedView.frame } func editMenuInteraction( _ interaction: UIEditMenuInteraction, menuFor configuration: UIEditMenuConfiguration, suggestedActions: [UIMenuElement] ) -> UIMenu? { let duplicateAction = UIAction(title: "Duplicate") { ... } return UIMenu(children: suggestedActions + [duplicateAction]) } -
10:34 - Using the "keeps menu presented" attribute
UIAction(title: "Increase", image: UIImage(systemName: "increase.indent"), attributes: .keepsMenuPresented) { ... } UIAction(title: "Decrease", image: UIImage(systemName: "decrease.indent"), attributes: .keepsMenuPresented) { ... } -
12:46 - Find with system views
open var findInteraction: UIFindInteraction? { get } textView.isFindInteractionEnabled = true -
17:22 - Installing a UIFindInteraction on a custom view
let customDocument = MyDocument(string: "") lazy var customView = MyTextView(document: customDocument) lazy var findInteraction = UIFindInteraction(sessionDelegate: self) override var canBecomeFirstResponder: Bool { true } override func viewDidLoad() { customView.addInteraction(findInteraction) } func findInteraction(_ interaction: UIFindInteraction, sessionFor view: UIView) -> UIFindSession? { return UITextSearchingFindSession(searchableObject: customDocument) }
-