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

前端 未结 2 1056
走了就别回头了
走了就别回头了 2021-01-27 13:04

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

相关标签:
2条回答
  • 2021-01-27 13:48

    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.

    0 讨论(0)
  • 2021-01-27 14:01

    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.

    0 讨论(0)
提交回复
热议问题