15
feb
Hi all!
By chance i founded this tricks that permit to show a “Dictionary definition” for the selected word in a UITextField on a hidden menu.
Menu contains these actions:
It’s a cool tricks, that show an hidden menu with a lot of options, that i never see before!
Watch this:



And this is the dictionary definition for pizza on simulator:

How?
Subclass UITextField and override:
1 2 3 | - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { return [super canPerformAction:action withSender:sender]; } |
Instead, if you want to block one or more actions from menu, add sel_isEqual:
1 2 3 4 5 6 7 | - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { if ( sel_isEqual(action, @selector(paste:)) ) return NO; if ( sel_isEqual(action, @selector(copy:)) ) return NO; // [...] etc etc return [super canPerformAction:action withSender:sender]; } |
that’s all!
enjoy.
Ref: albertopasca.it



