如何实现splitview for iphone os 4.2? [英] How implement splitview for iphone os 4.2?

查看:85
本文介绍了如何实现splitview for iphone os 4.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了自定义splitview。

I have use the custom splitview in the my application.

自定义splitview .h文件

custom splitview .h file

@interface CustomUISplitViewController :UISplitViewController {

BOOL keepMasterInPortraitMode;
BOOL  keepMasterInPortraitMode1;
 }

和.m文件

-(void) viewWillAppear:(BOOL)animated {

    keepMasterInPortraitMode1=keepMasterInPortraitMode;
    if(keepMasterInPortraitMode1 == NO) {
        if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            UIViewController* master = [self.viewControllers objectAtIndex:0];
            UIViewController* detail = [self.viewControllers objectAtIndex:1];
            [self setupPortraitMode:master detail:detail];      
        }
    }

    if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        UIViewController* master = [self.viewControllers objectAtIndex:0];
        UIViewController* detail = [self.viewControllers objectAtIndex:1];
        [self setupPortraitMode:master detail:detail];
      } 
     }
}

 - (void)setupPortraitMode:(UIViewController*)master detail:(UIViewController*)detail {
    //adjust master view
    CGRect f = master.view.frame;
    f.size.width = 220;
    f.size.height = 1024;
    f.origin.x = 0;
    f.origin.y =0;

    [master.view setFrame:f];

    //adjust detail view
    f = detail.view.frame;
    f.size.width = 548;
    f.size.height = 1024;
    f.origin.x = 221;
    f.origin.y = 0;

    [detail.view setFrame:f];
}

这在iOS4.0下正常工作但在4.2下我只看到一个视图该应用运行。 OS版本之间可能有什么变化?

This works correctly under iOS4.0 but under 4.2 I see only one view when the app runs. What could change between OS versions?

推荐答案

我的应用程序遇到了完全相同的问题。我使用了相同的Subclassing技术,在Portrait和Landscape模式下都可以看到Master和Detail。工作得很好,直到4.2,遗憾的是我没有测试Beta版本何时可用。

I have had the exact same problem with my applications. I had used the same Subclassing technique to have the Master and Detail visible in both Portrait and Landscape modes. Worked great until 4.2 which, unfortunately I didn't test for when the Beta releases were available.

我建议尝试优秀的MGSplitViewController( http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad )。它是UISplitViewController的开源实现。唯一的缺点是它在Interface Builder中使用起来并不那么容易,但它包含一个示例项目。在视觉上它与UISplitViewController相同,但增加了对几个附加功能的支持,例如在运行时拖动分割位置。

I recommend trying the excellent MGSplitViewController (http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad). It is an open-source implementation of the UISplitViewController. It's only drawback is that it isn't quite as easy to use in Interface Builder, but it includes a sample project. Visually it is identical to UISplitViewController, but adds support for several extras such as dragging the split position at runtime.

只需将其实现为UISplitViewController,但在某处添加以下行:

Just implement it exactly as your UISplitViewController but add the following line somewhere:

[splitViewController setShowsMasterInPortrait:YES];

这与Apple禁止在其版本中使用的私有API非常相似。

This is very similar to the Private API that Apple prohibits using with their version.

//[splitViewController setHidesMasterViewInPortrait:NO];  // Naughty, Naughty, Not allowed by the Apple police

这篇关于如何实现splitview for iphone os 4.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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