Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build errors on iOS 14, Xcode 12.3, Swift 5 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Context Menus.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
6 changes: 3 additions & 3 deletions Context Menus/CollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class CollectionViewController: UICollectionViewController {
// MARK: -UICollectionViewDelegate

override func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { actions -> UIMenu<UIAction>? in
let action = UIAction(__title: "Archive", image: UIImage(systemName: "archivebox.fill"), options: .destructive) { action in
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { actions -> UIMenu? in
let action = UIAction(title: "Archive", image: UIImage(systemName: "archivebox.fill"), identifier: UIAction.Identifier(rawValue: "archive")) { action in
let alert = UIAlertController(title: action.title, message: nil, preferredStyle: .alert)
alert.addAction(.init(title: "OK", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
}
return UIMenu<UIAction>.create(title: "Menu", children: [action])
return UIMenu(title: "Menu", children: [action])
}
return configuration
}
Expand Down
14 changes: 7 additions & 7 deletions Context Menus/SingleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ class SingleViewController: UIViewController {

extension SingleViewController: UIContextMenuInteractionDelegate {
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { actions -> UIMenu<UIAction>? in
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { actions -> UIMenu? in
// Creating Save button
let save = UIAction(__title: "Save", image: UIImage(systemName: "tray.and.arrow.down.fill"), options: []) { action in
let save = UIAction(title: "Save", image: UIImage(systemName: "tray.and.arrow.down.fill"), identifier: .init("save")) { action in
// Just showing some alert
self.showAlert(title: action.title)
}

// Creating Rotate button
let rotate = UIAction(__title: "Rotate", image: UIImage(systemName: "arrow.counterclockwise"), options: []) { action in
let rotate = UIAction(title: "Rotate", image: UIImage(systemName: "arrow.counterclockwise"), identifier: UIAction.Identifier(rawValue: "rotate")) { action in
self.showAlert(title: action.title)
}
// Creating Delete button
let delete = UIAction(__title: "Delete", image: UIImage(systemName: "trash.fill"), options: .destructive) { action in
let delete = UIAction(title: "Delete", image: UIImage(systemName: "trash.fill"), identifier: UIAction.Identifier(rawValue: "delete")) { action in
self.showAlert(title: action.title)
}
// Creating Edit, which will open Submenu
let edit = UIMenu<UIAction>.create(title: "Edit...", children: [rotate, delete])

let edit = UIMenu(title: "Edit...", children: [rotate, delete])
// Creating main context menu
return UIMenu<UIAction>.create(title: "Menu", children: [save, edit])
return UIMenu(title: "Menu", children: [save, edit])
}
return configuration
}
Expand Down
11 changes: 3 additions & 8 deletions Context Menus/TableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,15 @@ class TableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: { () -> UIViewController? in
return PreviewViewController.controller()
}) { _ -> UIMenu<UIAction>? in
let action = UIAction(__title: "Custom action", image: nil, options: []) { action in
}) { _ -> UIMenu? in
let action = UIAction(title: "Custom action", image: nil, identifier: UIAction.Identifier(rawValue: "custom identifier")) { action in
self.showAlert(title: action.title)
}
return UIMenu<UIAction>.create(title: "Menu", children: [action])
return UIMenu(title: "Menu", children: [action])
}
return configuration
}

override func tableView(_ tableView: UITableView, willCommitMenuWithAnimator animator: UIContextMenuInteractionCommitAnimating) {
animator.addCompletion {
self.showAlert(title: "Row preview tapped")
}
}
}