Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios4 如何为iphone os 4.2实现splitview?_Ios4_Ipad - Fatal编程技术网

Ios4 如何为iphone os 4.2实现splitview?

Ios4 如何为iphone os 4.2实现splitview?,ios4,ipad,Ios4,Ipad,我已经在我的应用程序中使用了自定义splitview 自定义splitview.h文件 @interface CustomUISplitViewController :UISplitViewController { BOOL keepMasterInPortraitMode; BOOL keepMasterInPortraitMode1; } 而.m文件是 -(void) viewWillAppear:(BOOL)animated { keepMasterInPortraitM

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

自定义splitview.h文件

@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下,当应用程序运行时,我只看到一个视图。操作系统版本之间会有什么变化?

我也遇到了同样的问题,我相信这是一个月前我提交的一个苹果bug,他们没有回应。对我来说,当应用程序在OrienceUIInterfaceOrientationAndscapeRight 3上启动时,详细视图是空白的。它看起来像这样:。当我将两个视图控制器中的一个(例如,RootViewController)限制为仅横向时,就会出现这种情况:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
有了此选项,在详图视图的初始化过程中将发生以下情况:

2010-11-15 20:17:47.792 MultipleDetailViews[96250:207] firstDetailViewController willAnimateRotationToInterfaceOrientation: 3 (landscape)
2010-11-15 20:17:47.792 MultipleDetailViews[96250:207] self.view.hidden is: 0
2010-11-15 20:17:47.799 MultipleDetailViews[96250:207] rotating...
2010-11-15 20:17:47.848 MultipleDetailViews[96250:207] firstDetailViewController didRotateFromInterfaceOrientation
2010-11-15 20:17:47.849 MultipleDetailViews[96250:207] self.view.hidden is: 1
由于某些原因,局部视图在旋转到方向3时会神秘地隐藏起来。在Apple修复3.2版中没有出现的此错误之前,我的解决方法是在详图视图控制器中覆盖以下方法,在旋转完成后重新显示视图:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    self.view.hidden = NO;
}
编辑:如果您的详细视图不是splitViewController.view的直接子视图(例如,您正在使用UINavigationController),则需要在UISplitViewController中的详细视图一侧的最上面的视图上设置“隐藏”:


我的申请也有同样的问题。我使用了相同的子类化技术,使主视图和细节在纵向和横向模式下都可见。在4.2版本之前工作得很好,不幸的是,我没有测试Beta版本的可用性

我建议尝试使用优秀的MGSplitViewController。它是UISplitViewController的开源实现。它唯一的缺点是在Interface Builder中使用起来不太容易,但它包含一个示例项目。从外观上看,它与UISplitViewController相同,但增加了对一些额外功能的支持,例如在运行时拖动拆分位置

只需完全按照UISplitViewController实现它,但在某处添加以下行:

[splitViewController setShowsMasterInPortrait:YES];
这与苹果禁止在其版本中使用的私有API非常相似

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

不错。尽管苹果公司忽略了很多其他的缺陷,但这让我毛骨悚然。
//[splitViewController setHidesMasterViewInPortrait:NO];  // Naughty, Naughty, Not allowed by the Apple police