2012-02-10 30 views

回答

0

您是否嘗試在文本字段上長按手勢?您可以從中複製文本,但我不確定文本選擇。

下面的代碼是用長按手勢註冊文本字段。當長按了公認

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressed:)];             
[textField addGestureRecognizer:longPress]; 

然後回調函數:

-(void)longPressed:(UILongPressGestureRecognizer *)sender 
{ 
    NsLog(@"Text from text field is %@",((UITextField *)[sender view]).text); 
} 

嘗試了這一點。

+0

你知道的任何建議或教程? – TWcode 2012-02-12 16:51:15

+0

讓我在我的答案中發佈一些代碼! – cocoakomali 2012-02-12 17:16:11

+0

幾個錯誤消息....暗示NSlog的功能的decleration,使用未聲明的標識符'self' – TWcode 2012-02-12 20:58:38

0

設置UILongPressGestureRecognizer:並查看textFieldShouldBeginEditing:是否也被觸發?如果是,那麼你可以複製那裏的文本字段。我不知道是否會觸發或手勢識別器會「超過」它?

+0

將它複製到textField三重點擊會更好嗎? – TWcode 2012-02-11 19:04:00