0

このView Controllerを他のいくつかから提示します。に基づいて別の画像を提示するにはどうすればよいですか

  1. これを提示したView Controller
  2. 現在のインターフェースの向き

ContextualController現在、画面サイズの画像で上に開くボタンがあります。ボタンを押した場所に応じて、3 つの異なる画像を呼び出したいと思いますUIViewControllers

からと に電話しUIViewController1たい。からと に電話したい。context_1_landscapecontext_1_portraitUIViewController2context_2_landscapecontext_2_portrait

-(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];
    }
4

1 に答える 1

1

presentingViewControllerのプロパティを使用して、誰があなたを紹介したかを知ることができますUIViewController。私の提案は、presentingViewControllers のそれぞれに、表示するイメージ名 (またはイメージ自体) であるプロパティを持たせることです。次に、 (適切なクラスのオブジェクトにキャストする)に、縦向きまたは横向きに使用する画像を提供するviewDidLoadように依頼します。presentingViewController

于 2013-02-01T20:13:54.190 に答える