【发布时间】:2011-07-19 14:46:01
【问题描述】:
我想做什么
我想要的是应用程序顶部的图像视图,我可以控制它的外观。例如,在主页中我不想要横幅,但在另一个视图中我想要。这意味着如果我确实想要横幅,我必须向下移动整个视图。
我做了什么
以下内容在我的 App Delegate 中。基本上,我将横幅的 customTabBarController 视图向下移动了 145 像素。
if ([self.customTabBarController interfaceOrientation] == UIInterfaceOrientationPortrait) {
[customTabBarController.view setFrame:CGRectMake(0, 145, 768,1024-145)];
banner = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 145)];
}
else if ([self.customTabBarController interfaceOrientation] == UIInterfaceOrientationPortraitUpsideDown) {
[customTabBarController.view setFrame:CGRectMake(0,0, 768,1024-145)];
banner = [[UIImageView alloc] initWithFrame:CGRectMake(0, 768+145, 768, 145)];
}
banner.image = image;
banner.hidden = NO;
[self.window addSubview:banner];
问题是什么
现在,我已经完成了纵向部分,但是当我尝试改变方向时,图像也会随之改变方向;这意味着当我将 iPad 更改为横向和上下颠倒时,图像会向侧面倾斜。基本上,它始终位于 iPad 的一侧。
有人可以帮忙吗?也欢迎对其他方法提出建议。
编辑:我意识到我没有为横向实现 setFrame,但我想先实现它以实现倒置纵向,但代码不起作用。倒置时应用程序的外观是横幅位于底部且图像倒置。
【问题讨论】:
标签: objective-c ipad uiimageview orientation nswindow