Sto realizzando un'app per iphone simile all'app Messaggi che arriva sul telefono. Ho appena impostato la possibilità di copiare i messaggi tramite un UIMenuController, ma se la tastiera viene visualizzata e qualcuno tenta di copiare un messaggio, la tastiera si spegne (presumibilmente a causa del mio [cell becomeFirstResponder];
dove cell
è la cella del messaggio da copiare).Mostrando UIMenuController perde tastiera
C'è un modo per mostrare il messaggio Copia senza perdere la tastiera?
- (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];
}
}
Questo potrebbe funzionare, ma il MenuController verrà posizionato direttamente nel centro orizzontale della cella. –