有没有办法确定UIMenuController何时被解雇?我有一个(不可编辑的)文本区域,我在菜单显示时突出显示,当他们选择一个项目(简单)或取消(不可能?)时,我想取消突出显示它.
我正在创建一个类似于手机上的消息应用程序的iPhone应用程序.我只是设置了通过UIMenuController复制消息的能力,但是如果键盘正在显示并且有人试图复制消息,键盘就会消失(大概是因为我[cell becomeFirstResponder];在哪里cell复制了消息单元).
有没有办法显示复制邮件而不会丢失键盘?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath {
//...other cell setup stuff...
UILongPressGestureRecognizer *longPressGesture =
[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(showCopyDialog:)];
[cell addGestureRecognizer:longPressGesture];
return cell;
}
- (void)showCopyDialog:(UILongPressGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan)
{
ConvoMessageCell *cell = (ConvoMessageCell *)[gesture view];
NSIndexPath *indexPath = [self.tblConvo indexPathForCell:cell];
UIMenuController *theMenu = [UIMenuController sharedMenuController];
[cell becomeFirstResponder];
[theMenu setTargetRect:CGRectMake(menuX, menuY, 100, 100) inView:cell];
[theMenu setMenuVisible:YES animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)