खो देता है मैं फोन पर आने वाले संदेश ऐप के समान एक आईफोन ऐप बना रहा हूं। मैंने बस UIMenuController के माध्यम से संदेशों की प्रतिलिपि बनाने की क्षमता स्थापित की है, लेकिन यदि कीबोर्ड दिखा रहा है और कोई संदेश कॉपी करने का प्रयास करता है, तो कीबोर्ड चला जाता है (संभवतः मेरे [cell becomeFirstResponder];
की वजह से cell
संदेश सेल कॉपी किया जा रहा है)।दिखा रहा है कि UIMenuController कीबोर्ड
कीबोर्ड खोने के बिना कॉपी संदेश दिखाने का कोई तरीका है?
- (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];
}
}
यह काम कर सकता है, लेकिन मेनू नियंत्रक को सेल के क्षैतिज केंद्र में रखा जाएगा। –