Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Ios 根据显示视图控制器和方向显示不同的图像_Ios_Objective C - Fatal编程技术网

Ios 根据显示视图控制器和方向显示不同的图像

Ios 根据显示视图控制器和方向显示不同的图像,ios,objective-c,Ios,Objective C,我从其他几个方面介绍了这个视图控制器。如何根据不同的图像呈现不同的图像 哪个视图控制器显示了这一个 当前接口方向 现在我有一个按钮,在ContextualController上方打开,屏幕大小为图像。 我想根据我在三个不同的UIViewControllers中按下按钮的位置调用不同的图像 从UIViewController1我想调用context\u 1\u scape和context\u 1\u trait。从UIViewController2我想调用context\u2\u-scape和co

我从其他几个方面介绍了这个视图控制器。如何根据不同的图像呈现不同的图像

  • 哪个视图控制器显示了这一个
  • 当前接口方向
  • 现在我有一个按钮,在
    ContextualController
    上方打开,屏幕大小为图像。 我想根据我在三个不同的
    UIViewControllers
    中按下按钮的位置调用不同的图像

    UIViewController1
    我想调用
    context\u 1\u scape
    context\u 1\u trait
    。从
    UIViewController2
    我想调用
    context\u2\u-scape
    context\u2\u-trait

    -(void) viewDidLoad;
    {
        [super viewDidLoad];    
    
        if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft)||    (self.interfaceOrientation ==UIDeviceOrientationLandscapeRight)){
            UIImageView *imageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"context_1_landscape.png"]];
            [self.view addSubview:imageview];
        } 
        else if ((self.interfaceOrientation ==UIDeviceOrientationPortrait)||(self.interfaceOrientation ==UIDeviceOrientationPortraitUpsideDown)){
            UIImageView *imageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"context_1_portrait.png"]];
            [self.view addSubview:imageview];
        }
    

    您可以使用
    UIViewController
    presentingViewController
    属性找出是谁向您演示的。我的建议是让每个PresentingViewController都有一个属性,即要显示的图像名称(或图像本身)。然后在
    viewdiload
    中,您要求
    presentingViewController
    (投射到适当类别的对象)提供用于纵向或横向的图像。

    问题是如何以及在何处实现if/only语句以实现该功能?我对目标c不熟悉:(+1,或者让每个演示控制器在
    ContextualController
    中设置一个属性,告诉它要使用什么图像。这不需要额外的工作,而且它为演示控制器根据情况选择不同的图像打开了大门。谢谢大家的提示。如果可能的话,你能举个例子吗。我在这方面有点新手