ios - Add a UIMenuItem for a specific UITextView? -
i have lot of uitextview
s in screen , want add new custom uimenuitem
1 of them.
it possible add custom uimenuitem
specific uitextview
?
i use below code have custom button uitextview
s
uimenuitem *menuitem = [[uimenuitem alloc] initwithtitle:@"read" action:@selector(readbuttonaction)]; [[uimenucontroller sharedmenucontroller] setmenuitems:[nsarray arraywithobject:menuitem]];
thanks
if want uimenuitem
displayed specific uitextview
can add menuitem in textfielddidbeginediting
method , add specific tag uitextview
custom menu item displayed :-
-(void)textviewdidbeginediting:(uitextview *)textview { if(textview.tag==999) //specify textveiw want custom menu { [[nsoperationqueue mainqueue] addoperationwithblock:^{ uimenuitem *menuitem = [[uimenuitem alloc] initwithtitle:@"read" action:@selector(readbuttonaction)]; [[uimenucontroller sharedmenucontroller] setmenuitems:[nsarray arraywithobject:menuitem]]; }]; } }
Comments
Post a Comment