8

I have a messaging app. I have a UITabeView in ViewController. I implement my longPressGesture event on my Custom UITableViewCell like this to show UIMenuController on it ( copy - forward and ... ) :

AudioMsgCell

-(void)handleLongPress:(UIGestureRecognizer *)gesture
        [self becomeFirstResponder]; // i crash on this Line
        UIMenuController *menu = [UIMenuController sharedMenuController];
        UIMenuItem *delete = [[UIMenuItem alloc] initWithTitle:@"Delete" action:@selector(Delete:)];
        CGRect targetRect = [self convertRect:[self.bubbleImageView frame]
                                     fromView:self];
        [menu setMenuItems:[NSArray arrayWithObjects:delete,nil]];
        [menu setTargetRect:targetRect inView:self];
        [menu setMenuVisible:YES animated:YES];}

i have a XIB file include UITextField & some UIButton and in myviewController i addSubView to View.

TextingViewController

 [self.view addSubview:self.inputView];

when I do long press gesture on cell I get crash on the method

AudioMsgCell

 [self becomeFirstResponder]

I had this problem in past, when I implemented extrakeyboard in iOS 8 but now when do gesture on my Cell app crash with this error :

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x14459d620> should have parent view controller:<BLTextingViewController: 0x146801000> but requested parent is:<UIInputWindowController: 0x144a05a00>'

please look at this link : Error when adding input view to textfield iOS 8

if i remove addSubView in ViewController everything is ok But i cant't see View ( include TextField & ... )

UPDATE:

if the textField is first responder (this crash not happning). bug I want to touch my cell when keyboard is resign.

Chitra Khatri
  • 1,260
  • 2
  • 14
  • 31
Mo Farhand
  • 1,144
  • 8
  • 21
  • 1
    I'm guessing self.view is a UITableViewCell? So what is self.inputView? Maybe your inputView has a superview set from the XIB you are talking about that is should not have? Have you tried `[self.inputView removeFromSuperView]` before calling `[self.view addSubview:self.inputView]`. – Peter Segerblom Jul 29 '15 at 07:50
  • no dear peter [self.view addSubview:self.inputView]; in my viewController that i need add my inputView. --- > my input view is a View in XIB file & add it on my ViewController by addSubView – Mo Farhand Jul 29 '15 at 07:55
  • @PeterSegerblom please check again , i update my question – Mo Farhand Jul 29 '15 at 08:03
  • What do you want to become first responder? – Mike Jul 29 '15 at 08:22
  • @PeterSegerblom i want to show UIMenuControler on my CustomCell – Mo Farhand Jul 29 '15 at 08:26

0 Answers0