Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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
iphone UIView子类未按请求初始化_Iphone_Objective C_Ipad - Fatal编程技术网

iphone UIView子类未按请求初始化

iphone UIView子类未按请求初始化,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我对objective-c和iPhone的开发还不熟悉,但到目前为止,一切都进展顺利,直到我试着深入挖掘(不是太深入)。我的问题是,我无法使用不同方向的特定坐标初始化特定UIView子类 旋转效果很好,但问题是应用程序初始化的时间。我在考虑为不同的方向提供不同的布局 我的应用程序实际上是一个iPad应用程序,有一个主UIViewController和三个子视图(UIView)。让我们调用view1、view2和view3 这三个视图是在项目的nib上创建的,并为它们编码和连接插座 问题似乎是从v

我对objective-c和iPhone的开发还不熟悉,但到目前为止,一切都进展顺利,直到我试着深入挖掘(不是太深入)。我的问题是,我无法使用不同方向的特定坐标初始化特定UIView子类

旋转效果很好,但问题是应用程序初始化的时间。我在考虑为不同的方向提供不同的布局

我的应用程序实际上是一个iPad应用程序,有一个主UIViewController和三个子视图(UIView)。让我们调用view1、view2和view3

这三个视图是在项目的nib上创建的,并为它们编码和连接插座

问题似乎是从viewDidLoad方法生成的。。。目前看起来是这样的:

-(void)viewDidLoad{

    [super viewDidLoad];
    [view1 removeFromSuperview];
    [view2 removeFromSuperview];
    [view3 removeFromSuperview];

    UIInterfaceOrientation curOrientation = self.Orientation;

    if(curOrientation == UIInterfaceOrientationPortrait)
    {
       view1 = [[XView alloc] initWithFrame:CGRectMake(20,492,728,492)];
       view2 = [[YView alloc] initWithFrame:CGRectMake(384,20,364,472)];
       view3 = [[ZView alloc] initWithFrame:CGRectMake(20,20,364,472)];

       [self.view addSubview:view1];
       [self.view addSubview:view2];
       [self.view addSubview:view3];
    }
    else if(curOrientation == UIInterfaceOrientationLandscapeRight)
    {
      //Different coordinates
    }
    else if(curOrientation == UIInterfaceOrientationLandscapeLeft)
    {
     //Different Coodinates
    }

    }
我的问题是视图没有得到与viewDidLoad方法中给定的坐标相同的坐标,并且它们似乎在x=0,y=0时初始化。然而,当我旋转设备时,一切都像一个符咒一样工作,每个UIView都设置在每个方向的正确位置。基本上,我只是为每个UIView调用setFrame方法

我不确定我在这里做错了什么。。。。我需要帮助


您的视图是应用程序中加载的第一个视图吗?我发现在某些情况下,在第一次加载时,方向可以标记为UIDeviceOrientationUnknown

不管怎么说,看看你班上的其他同学可能会很有用。您的视图是否会显示为更改帧?self.view的维度是否正确