Reputation: 51
I created a pop over to view my settings like this,
if ([popoverController isPopoverVisible]) {
[popoverController
dismissPopoverAnimated:YES];
} else {
UIView* popoverView = [[UIView alloc]
initWithFrame:CGRectMake(566, 440, 0, 0)];
popoverView.backgroundColor = [UIColor blackColor];
controller1.contentSizeForViewInPopover = CGSizeMake(300, 115);
popoverController = [[UIPopoverController alloc]
initWithContentViewController:controller1];
[popoverController presentPopoverFromRect:popoverView.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
my push action code:
UIStoryboard *storyboard = [UIStoryboard
storyboardWithName:@"MainStoryboard"
bundle:nil];
UIViewController *controller = (UIViewController *)[storyboard
instantiateViewControllerWithIdentifier:@"PCBViewController"];
[self.navigationController
pushViewController:controller
animated:YES];
In my settings popover has some buttons. Those button is clicked, view controller open through push action but its not working.
My Question is: How to set push action for popover contents.
Upvotes: 0
Views: 650
Reputation: 708
you need to set up navigation controller for the view controller to allow navigation.
in your .h file
UINavigationController *navevent;
UIViewController *yourViewController
in .m file synthasize it and in view did load
navevent=[[UINavigationController alloc]initWithRootViewController:yourViewController];
yourViewController=[[UIViewController alloc]init];
then create your popover like this
yourViewController.view = yourView;
self.popoverController = [[UIPopoverController alloc]initWithContentViewController:navevent] ;
hope this help
Upvotes: 0
Reputation: 9836
Your view is presented from popover thus self.navigationController will be nil.
Try this
UIStoryboard *storyboard = [UIStoryboard
storyboardWithName:@"MainStoryboard"
bundle:nil];
UIViewController *controller = (UIViewController *)[storyboard
instantiateViewControllerWithIdentifier:@"PCBViewController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[navigationController
pushViewController:controller
animated:YES];
Upvotes: 1