繁体   English   中英

核心图-使图形全屏显示的选项-出现模态问题后的addSubview

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

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

我将Core Plot图(corePlotView)添加到了500x350 UIView(myView)中,并通过长按成功“呈现”了它:

-(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。

-(IBAction)close:(id)sender {

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

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

-(void)reloadOriginalGraph {

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

[corePlotView loadOriginalGraph]和[corePlotView loadFullGraph]是调用方法,可将所有文本大小和填充类型属性从原始设置切换为全屏设置...这不是问题。

问题在于,当iPad成功旋转时,将图的大小成功地缩小为500x350时,corePlotView会立即重新调整为模态视图的框架大小。 显然,这不是我想要的,因为需要以某种方式维护或限制500x350。

有没有人在介绍模态然后使用addSubview时遇到这个问题? 此方法可在ARC有机会删除视图之前将视图保留在堆栈上,但该模式的某些属性似乎保持不变。 有没有办法从UIViewController剥离这种“模式”?

有没有更简单的方法可以将Core Plot图设置为全屏并使用手势再次返回(似乎捏手势未在corePlotView上注册,这就是为什么我要长时间按下的原因)?

iOS托管视图使用捏合手势允许捏合缩放绘图空间。 如果您希望使用其他行为,请将托管视图的allowPinchScaling属性设置为NO以删除默认手势识别器。

在“足够”地使用了presentViewController之后,我决定将Core Plot图全屏显示的最佳外观和最安全方法是:

苹果手机

-(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中旋转时视图层次结构和崩溃的大量问题。

注意:请注意iPhone代码。 我发现,如果您有一个除了corePlotVC之外不会旋转的应用程序,则可能会看到导航栏出现在状态栏后面的情况。 我现在正在解决这个问题,但是这段代码可以按原样节省很多人的时间,因此,花点时间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM