【问题标题】:Copy/paste UIMenuItem not showing in all my application复制/粘贴 UIMenuItem 未显示在我的所有应用程序中
【发布时间】:2020-04-28 00:53:58
【问题描述】:

我的所有应用程序(最低目标 iOS13)中都出现了一个问题:在 UISearchBar 和 UITextFieald 中都没有显示 UIMenuController。

我尝试继承 UITextField 并覆盖 canPerformAction,触发了 func,我返回 true 但没有任何反应..

谁能帮忙,谢谢。

【问题讨论】:

  • 你能添加与该功能相关的代码
  • @Kalana 请看我的回答

标签: ios xcode uitextfield uisearchbar uimenucontroller


【解决方案1】:

问题是sceneDelegate中“window.makeKeyAndVisible()”的调用

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

        guard let windowScene = (scene as? UIWindowScene) else { return }        
        let window = UIWindow(frame: UIScreen.main.bounds)
        window.rootViewController = TabBarController()
        // i delete this line and the UIMenuController are displayed ! 
        -> window.makeKeyAndVisible()<-
        self.window = window
        self.window?.windowScene =  windowScene
        self.window!.makeKeyAndVisible()
    }

【讨论】:

  • 如果您在堆栈溢出中搜索更多位,您可能会找到答案。看看这个 -> stackoverflow.com/questions/59176844/…
  • 已接受的评论建议调用 func,但我必须删除它才能使其工作..
  • 是的,这有点相反。
  • 添加您之前的代码,在您找到问题的答案之前,除非您的问题会因为细节较少而关闭
  • 请同时添加这个工作的原因。这对我们所有人都有好处。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-19
相关资源
最近更新 更多