【发布时间】:2013-02-02 04:30:10
【问题描述】:
我从其他几个人那里展示了这个视图控制器。如何根据不同的图像呈现不同的图像
- 哪个视图控制器呈现了这个
- 当前界面方向
现在我有一个在ContextualController 上方打开的按钮,带有屏幕大小的图像。
我想根据我在三个不同的UIViewControllers 中按下按钮的位置来调用不同的图像。
来自UIViewController1 我想打电话给context_1_landscape 和context_1_portrait。从UIViewController2 我想打电话给context_2_landscape 和context_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];
}
【问题讨论】:
-
问题是我如何以及在哪里实现 if/only 语句以使其工作?
-
我是目标 c 的新手 :(
标签: ios objective-c