0

Unable to navigate to a controller using the UIPopoverPresentationController _passthroughViews method in iOS using Objective C.

I am trying to navigate to the controller view using the UIPopoverPresentationController's passthroughView. But I can't able to set this navigation and get an error and the app gets crashed. How can I resolve this?

Here I am additionally facing an error with the last item in the popover shows as a footer or not movable label and if I click this, there is no highlights, Code:

SelectorViewController* sv = [[SelectorViewController alloc] initWithStyle:UITableViewStylePlain];
sv.delegate = self;
sv.currentTopic = self.title;
NSLog(@" sv.currentTopic%@", sv.currentTopic);
sv.preferredContentSize = CGSizeMake(300, 500);
sv.modalPresentationStyle = UIModalPresentationPopover;
        
UIPopoverPresentationController *popoverpresentationController = sv.popoverPresentationController;
popoverpresentationController.delegate = self;
popoverpresentationController.sourceView = sender.view;
 [self present view controller:sv animated: YES completion: nil];  
   popover.delegate = self;
   if ([popover respondsToSelector:@selector(setBackgroundColor:)])
         popover.backgroundColor = [UIColor whiteColor];
         [sv release];
sejn
  • 2,040
  • 6
  • 28
  • 82
  • Can you add more details like what you are looking to achieve or a sample app which can reproduce the issue ? Didn't understand what is the value of _passthroughViews and why you are presenting twice in your code – Midhun MP May 04 '23 at 16:28
  • "But I can't able to set this navigation and get an error and the app gets crashed" Could you share the full error message? – Larme May 06 '23 at 12:09
  • You should add error message what it say. Also i saw typo there: [[electorViewController alloc]. Missing an "s"? – GeneCode May 07 '23 at 03:14
  • UINavigationBar decoded as unlocked for UINavigationController, or navigationBar delegate set up incorrectly. Inconsistent configuration may cause problems. – sejn May 08 '23 at 10:53

1 Answers1

0

It seems you're trying to present a popover from a view controller and setting passthroughViews to the navigation controller's delegate. The passthroughViews property of UIPopoverPresentationController is an array of views.

The correct usage should be:

// Assuming `view1` and `view2` are views that you want the user to interact with while the popover is visible
popoverpresentationController.passthroughViews = @[view1, view2];

If you want to navigate to another controller when the popover is presented, you can do that in the popover's delegate method, popoverPresentationControllerDidDismissPopover.

As for the issue where you're not able to interact with the content, make sure that the popover's preferredContentSize is big enough to display the tableview and its cells fully. Also, check the tableview's contentSize.

Marcos Curvello
  • 873
  • 13
  • 25
  • I have controller and one of the two values are differ I think. Because it opens in a popup window. So while click on the title it not navigating to the app – sejn May 12 '23 at 13:53