Core Plot - 使图形全屏显示的选项 - 在呈现模态问题后添加子视图 [英] Core Plot - Options on making the graph full screen - addSubview after presenting modal problems

查看:112
本文介绍了Core Plot - 使图形全屏显示的选项 - 在呈现模态问题后添加子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个多方面的问题,可以帮助那些使用Core Plot的人,或那些在模式上呈现UIViewController时遇到问题的人,然后尝试将其作为子视图添加到较小的UIView。

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 to a smaller UIView.

我有一个Core Plot图(corePlotView)添加到500x350 UIView(myView)并使用长按成功呈现它:

I have a Core Plot graph (corePlotView) added to a 500x350 UIView (myView) and am successfully presenting it "modally" using a long press:

-(void)press:(UILongPressGestureRecognizer*)gesture {

    if(gesture.state == UIGestureRecognizerStateEnded)
    {
        corePlotView.closeBtn.hidden = NO;
        corePlotView.iPadCV = self;
        [corePlotView loadFullGraph];
        [ipadDelegate.detailViewController presentViewController:corePlotView animated:NO completion:nil];
    }
}

这是制作全屏图表的简便方法在iPad旋转时显示并仍然调整图形大小(非常重要)。当用户点击closeBtn时,会从corePlotView向dismissModalViewController发送一条消息......

This is an easy way of making a full screen graph appear and still resize the graph when the iPad is rotated (very important). When the user clicks "closeBtn," a message is sent to dismissModalViewController from corePlotView...

-(IBAction)close:(id)sender {

    self.closeBtn.hidden = YES;
    ipadDelegate = (AppDelegate_iPad *)[[UIApplication sharedApplication] delegate];
    [ipadDelegate.detailViewController dismissViewControllerAnimated:NO completion:nil];
    [iPadCV reloadOriginalGraph];
}

...然后reloadOriginalGraph维护用户在呈现之前的所有图表和数据(重要),然后将视图重新调整为原始帧,如下所示:

...then reloadOriginalGraph maintains all the plots and data the user had before presenting (important), then resizes the view back into its original frame like this:

-(void)reloadOriginalGraph {

    [corePlotView.view setFrame:myView.bounds];
    [corePlotView loadOriginalGraph];
    [myView addSubview:corePlotView.view];
    [myView sendSubviewToBack:corePlotView.view];
}

[corePlotView loadOriginalGraph]和[corePlotView loadFullGraph]正在调用方法来切换所有从原始设置到全屏设置的文本大小和填充类型属性...不是问题。

The [corePlotView loadOriginalGraph] and [corePlotView loadFullGraph] are calling methods that toggle all the text sizes and padding type properties from orginal settings to full screen settings...not the problem.

问题是当图形成功缩小到500x350时,一旦iPad旋转,corePlotView就会调整回模态视图的框架。显然,这不是我想要的,因为500x350需要以某种方式维护或约束。

The problem is when the graph is sized back down successfully to 500x350, as soon as the iPad is rotated, the corePlotView resizes back to the frame of the modal view. Obviously, this isn't what I want, as the 500x350 needs to be maintained or constrained in some way.

有人在呈现模态时遇到此问题然后使用addSubview?在ARC有机会删除它之前,此方法使视图保持在堆栈上,但似乎模态的某些属性保持不变。有没有办法从UIViewController中删除这个模态?

Has anyone ran into this problem when presenting a modal then using addSubview? This method keeps the view live on the stack before ARC has a chance to remove it, but it seems like some attributes of the modal stay persistent. Are there ways to strip this "modality" from a UIViewController?

是否有更简单的方法将Core Plot图形设置为全屏并使用手势再次返回(似乎是pinch手势没有在corePlotView上注册,这就是为什么我使用长按)?

Is there an easier way to set a Core Plot graph to full screen and back again using gestures (seems like pinch gestures are not registered on the corePlotView, which is why I'm using a long press)?

推荐答案

使用presentViewController后够了,我认为制作核心情节图全屏的最佳外观和最安全的方法是:

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];
}
}

在这种情况下,为避免收缩冲突,我用过长按手势。请注意,对于iPad,来自UISplitViewController的appDelegate.splitViewController.view。它正在使用UIPopoverController,在iOS 6中旋转时消除了大量的视图层次结构和崩溃问题。

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.

注意:小心使用iPhone代码。我发现如果你有一个不旋转的应用程序,除了corePlotVC,你可能会看到navBars的出现落后于状态栏。我现在正在努力解决这个问题,但是这段代码可以为很多人节省一些时间,所以有了它。

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.

这篇关于Core Plot - 使图形全屏显示的选项 - 在呈现模态问题后添加子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆