没有收到来自UITextField的canPerformAction:withSender的'paste:'动作

时间:2012-08-28 17:04:19

标签: ios5 uitextfield

我想为UITextField禁用'粘贴'选项,在我的UITextField的委托类中,我提供了一个实现:

-(BOOL)canPerformAction:(SEL)action withSender:(id)sender 

NSObject(UIResponderStandardEditActions)定义了以下操作,我将所有这些操作发送给canPerformAction paste:除了@interface NSObject(UIResponderStandardEditActions) // these methods are not implemented in NSObject - (void)cut:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); - (void)copy:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); - (void)paste:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); - (void)select:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); - (void)selectAll:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); - (void)delete:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_2); - (void)makeTextWritingDirectionLeftToRight:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); - (void)makeTextWritingDirectionRightToLeft:(id)sender __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); @end

{{1}}

现在,只要剪贴板中有内容并且我将焦点放在UITextField上,我就会看到“粘贴”菜单。

我还应该做些什么来接收粘贴消息吗?

1 个答案:

答案 0 :(得分:1)

创建UITextField的子类并覆盖canPerformpaste:上的UITextField操作被调用,delegate