【发布时间】:2011-06-20 17:02:45
【问题描述】:
对于以下代码,我需要根据 iphone 和 ipad 方向设置不同的 UIIMageView 位置。
// Animated images - centered on screen
animatedImages = [[UIImageView alloc] initWithFrame:CGRectMake(
(SCREEN_WIDTH / 2) - (IMAGE_WIDTH / 2),
(SCREEN_HEIGHT / 2) - (IMAGE_HEIGHT / 2) + STATUS_BAR_HEIGHT,
IMAGE_WIDTH, IMAGE_HEIGHT)];
因为 ipad 纵向、iphone 纵向、ipad 横向和 iphone 横向的 CGRect 会有所不同。
我该怎么做
if (Ipad Portrait orientation)
{
code with different position using CGRectMake (...............)
}
if (Iphone Portrait orientation)
{
code with different position using CGRectMake (...............)
}
if (Ipad Landscape orientation)
{
code with different position using CGRectMake (...............)
}
if (Iphone Landscape orientation)
{
code with different position using CGRectMake (...............)
}
【问题讨论】:
-
请格式化您的帖子,并使用代码标签,以便阅读。
标签: iphone ios4 orientation cgrect