2

I am trying to display a simple iPad popover which contains a navigationController with a tableView.

popover -> navigation controller -> view controller -> table view.

I do need the navigationController because on touching the cells I want to push another viewController (within that same popover).

Without the navigation controller, everything is fine. But as soon as I put the viewController inside a navigationController, the tableView stops responding (didSelectRow doesn't get called). I suppose something is wrong with my delegates but I just can't work it out.

. The navigationController responds fine (I can hit a button I have in the top bar)

. The buttons that are IN the cells respond fine.

. If I touch down and hold on a cell it gets highlighted, but not selected.

UPDATE: I just found out that if I hold the cell down for at least a second, the delegate is called when I release it. any less than that and it is never called...???

Here is the code use:

ModalViewController* controllerWithTable = [[self storyboard] instantiateViewControllerWithIdentifier:identifier];

UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:controllerWithTable];

UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
popover.delegate = self;

[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Endive au Jambon
  • 461
  • 1
  • 4
  • 9

2 Answers2

0

If you are using a popoverController to show a table view, you don't need to embed it in a navigation Controller, Instead make a different Viewcontroller with the table view and just shoe that inside a popover controller .I used it somewhat like this..

Make a global reference for UIPopoverController in your app delegate, //in your Appdelegate.h file declare this @property(strong, nonatomic) UIPopoverController *popOverForTableView;

Now In the controller which you want to show the PopOver view use this,

 TableViewCOntroller* popoverContent = [[TableViewCOntroller alloc] init];

  NSString *identifier=@"tableVC"
  popoverContent =[[UIStoryboard storyboardWithName:@"Main"
                                               bundle:nil]
                     instantiateViewControllerWithIdentifier:identifier];
  popoverContent.preferredContentSize = CGSizeMake(330, 280);


    AppDelegate *appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];

    appDelegate. popOverForTableView = [[UIPopoverController alloc]initWithContentViewController:popoverContent];
    appDelegate.popOverForTableView.delegate = self;
    appDelegate.popOverForTableView.backgroundColor=[UIColor blackColor];
    [appDelegate.popOverForTableView  presentPopoverFromRect:self.date.frame inView:self.view  permittedArrowDirections:(UIPopoverArrowDirectionUp) animated:YES];

You can dismiss it accordingly…,…see if this Helps..

Geet
  • 2,427
  • 2
  • 21
  • 39
  • Thanks, I do need the navigationcontroller though because on hitting the cells I need to push another viewController within that same popover. I will edit my question to make it clearer – Endive au Jambon May 26 '14 at 10:12
  • well then on hitting the cell just present the detail view controller instead of push.....try using presentmodalViewCOntroller method – Geet May 26 '14 at 10:19
  • Oh right good idea that would be my solution if I can't fix this, but it sort of makes sense UI-wise that the view comes from the right. – Endive au Jambon May 26 '14 at 10:39
  • see my updated question, just noticed that if I hold the cell down for a good second it does get selected... – Endive au Jambon May 26 '14 at 10:58
  • can you check your table vVIew didSelectRowAtIndex method, Check If its getting called, If it is then I think theres some problem with the code You have written there – Geet May 26 '14 at 11:03
  • after holding it down for a while the method is called yes. see my answer below, the tap was being stolen by a tapResponder on the parent view. Thanks for looking into it anyway! – Endive au Jambon May 26 '14 at 11:10
0

Ok I found the answer there: https://stackoverflow.com/a/18159463/3562952

The tableView was not irresponsive, it was deceptively responding only after a 1-3 seconds hold down.

I had a tap responder on the parent view that was capturing the tap. I am now removing it when displaying the popover and putting back in on dismissal.

I was googling for the wrong symptoms :)

Community
  • 1
  • 1
Endive au Jambon
  • 461
  • 1
  • 4
  • 9