This is a multifaceted question that can help those using Core Plot, or those who are having problems presenting a UIViewController modally, then trying to add it as a subview t
The iOS hosting view uses a pinch gesture to allow pinch scaling of the plot space. If you'd rather have a different behavior, set the allowPinchScaling
property of the hosting view to NO
to remove the default gesture recognizer.
After working with presentViewController "enough," I decided that the best looking and safest way to make a Core Plot graph full screen was this:
IPHONE
-(void)press:(UILongPressGestureRecognizer*)gesture {
if(gesture.state == UIGestureRecognizerStateEnded)
{
[corePlotVC removeFromParentViewController];
vc = [[UINavigationController alloc] initWithRootViewController:corePlotVC];
vc.navigationBar.hidden = YES;
corePlotVC.closeBtn.hidden = NO;
corePlotVC.view.autoresizingMask = UIInterfaceOrientationMaskAll;
[corePlotVC loadFullGraph];
[details presentViewController:vc animated:NO completion:nil];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
}
}
IPAD
-(void)press:(UILongPressGestureRecognizer*)gesture {
if(gesture.state == UIGestureRecognizerStateEnded)
{
[corePlotVC removeFromParentViewController];
popover = [[UIPopoverController alloc] initWithContentViewController:corePlotVC];
[popover setPopoverContentSize:CGSizeMake(1024, 1024)];
popover.passthroughViews=[NSArray arrayWithObject:appDelegate.splitViewController.view];
[popover presentPopoverFromRect:CGRectZero
inView:appDelegate.splitViewController.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
corePlotVC.closeBtn.hidden = NO;
[corePlotVC loadFullGraph];
}
}
In this case, to avoid pinching conflicts, I used a long press gesture. Notice that for the iPad, appDelegate.splitViewController.view from a UISplitViewController. It was using a UIPopoverController that eliminated a ton of problems with view hierarchies and crashes when rotating in iOS 6.
NOTE: Careful with the iPhone code. I've found that if you have an app that doesn't rotate, except the corePlotVC, you might see occurrences of navBars falling behind the status bar. I'm working through that now, but this code can save a lot of people some time as is, so have at it.