Post

Replies

Boosts

Views

Activity

UIMenuController broken in SwiftUI iOS 13.5
Trying to modify the UIMenuController and I am no longer able to do so in a iOS 13.5 SwiftUI project. import SwiftUI struct ContentView: View { 		var body: some View { 				MyTextViewRepresentable() 		} } struct ContentView_Previews: PreviewProvider { 		static var previews: some View { 				ContentView() 		} } struct MyTextViewRepresentable: UIViewRepresentable {		 		 		func makeUIView(context: Context) -> MyTextView { 				let textView = MyTextView() 				textView.text = "Double click on me in order to test. I am not supposed to display any menu options because my canPerformAction() is returning false. I am work just fine in a Storyboard." 				textView.isEditable = false				 				 				return textView 		} 		 		func makeCoordinator() -> Coordinator { 				Coordinator() 		} 		 		func updateUIView(_ uiView: MyTextView, context: Context) { } } class MyTextView: UITextView { 		override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { 				return false // Remove all menu options 		} } The code below works fine in a Storyboard project. import UIKit class ViewController: UIViewController, UITextViewDelegate {     fileprivate func createTextView() {         let textView = MyTextView(frame: CGRect(x: 0, y: 50, width: 500, height: 100))         textView.text = "Double click on some text. I am not supposed to display any menu options because my canPerformAction() is returning false. I am working fine because I was built by only importing UIKit inside of my Storyboard project."         textView.isEditable = false         view.addSubview(textView)     }     override func viewDidLoad() {         super.viewDidLoad()         createTextView()     } } class MyTextView: UITextView {     override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {         return false     } }
3
0
1.4k
Jun ’20