2017-08-18 47 views
0

我顯示了在uiviewconroller這樣一個UIMenuController:UIMenuController不隱藏系統項目

在我的課

override open func canBecomeFirstResponder() -> Bool { 
    return true 
} 

open override func canPerformAction(_ action: Selector, withSender sender: Any) -> Bool { 

    //here I check for my custom action, else return false 
    return false 
} 

然後顯示我用:

//Make this as first responder 
    self.becomeFirstResponder() 

    ///Build menu 
    let menu = UIMenuController.shared 
    ///Set item and anchor point, and showit 
    menu.menuItems = itemsToAdd 
    menu.setTargetRect(CGRect(x: 0, y: 5, width: bubbleNode.view.bounds.size.width, height: bubbleNode.view.bounds.size.height), in: bubbleImageNode.view) 
    menu.setMenuVisible(true, animated: true) 

問題是在設備中顯示我的自定義項目,還有:「拼寫,說,點句,ecc ...」我如何禁用它?

+0

菜單上沒有會員代表 –

+0

你的控件是UITextView? –

+0

是ASCellNode,AsyncDisplayKit的一個collectionviewcell –

回答

0

重寫canPerformAction併爲每個特定操作處理它。它完美地爲我工作。

override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { 

     var canPerform = super.canPerformAction(action, withSender: sender) 

     if (action == "your action to restrict") { 
       canPerform = false 
     } 

     return canPerform 
    } 
+0

同樣的錯誤...我看到,只要加載視圖,如果我長按視圖,我只看到我的自定義項目,1或2秒後,如果我再次longpress我看到我的項目和系統項目 –

0

好了,問題是「輔助功能」選項,在我的設備「說話的選擇」,如果我禁用它,我只看到了自定義項目,但在其他應用程序,我只看到在啓用該選項自定義項目!