Core Plot - Options on making the graph full screen - addSubview after presenting modal problems

こ雲淡風輕ζ 提交于 2019-12-02 09:58:39

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!