,你应该能够使用一些简单的逻辑来换出图片:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
//The following if statement determines if it is an iPad, if it is then the interface orientation is allowed. This line can be taken out to support both iPhones an iPads.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
//Swap images and use animations to make the swap look "smooth"
//NSLog(@"Landscape Right");
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
//Swap images and use animations to make the swap look "smooth"
//NSLog(@"Landscape Left");
} else {
//Swap images and use animations to make the swap look "smooth"
//NSLog(@"Portrait");
}
} else {
}
}
要在界面编程方式更改图像:
[myUIImageView setImage:[UIImage imageNamed:@"myImage.png"]];
此外,为了请确保视图不会自动旋转,请使用shouldAutorotateToInterfaceOrientation
方法来告诉您的应用保持肖像状态。
据我的经验告诉,嵌套UIViewControllers不会启用“底部”UIViewController来接收自动旋转方法。我也可能会使用'affineTransform'。 – bddckr 2010-04-16 20:26:27
@ChriB很高兴知道!正如我所说,我不确定这是否会起作用。 :) – 2010-04-16 20:54:54