ios - How to use More menucontroller in View controller -


can me, i'm having problem uimenucontroller.in here, have use 2 menucontroller in single viewcontroller. first menu "paste",for other menu "copy","select","select all" when i'm using shared menucontroller affects other menu.

my code first menu follows:

override func canbecomefirstresponder() -> bool {     return true }  override func canperformaction(action: selector, withsender sender: anyobject?) -> bool {    //actions  }   uimenucontroller.sharedmenucontroller().menuitems = nil      let select: uimenuitem = uimenuitem(title: "select", action: selector("select"))     let selectall: uimenuitem = uimenuitem(title: "selectall", action: selector("selectall"))     let copy: uimenuitem = uimenuitem(title: "copy", action: selector("copy"))       let menu: uimenucontroller = uimenucontroller.sharedmenucontroller()     menu.menuitems = [select,selectall,copy]     menu.settargetrect(cell.frame, inview: cell.superview!)     menu.setmenuvisible(true, animated: true) 

and second menu is:

 uimenucontroller.sharedmenucontroller().menuvisible = false  let paste: uimenuitem = uimenuitem(title: "paste", action: selector("paste"))  let menu: uimenucontroller = uimenucontroller.sharedmenucontroller() menu.menuitems = [paste]    menu.settargetrect(message_textfield.frame, inview:   message_textfield.superview!) menu.setmenuvisible(true, animated: true) 

error: in here,in second menu contains unwanted things [select,selectall,copy] [paste].

how can resolve this,thanks in advance

you should override canperformaction in uitextfield subclass disable item don't want, assign each uitextfield created subclass.

for example, disable paste menu item in uimenucontroller:

class customtextfield: uitextfield {     override func canperformaction(action: selector, withsender sender: anyobject?) -> bool {         if action == "paste:" {             return false         }          return super.canperformaction(action, withsender: sender)     } } 

usage:

let message_textfield = customtextfield() 

now paste menu item disabled message_textfield


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -