我必须为相应的方向显示两个不同的图像。我通过使用Nib文件在一个UIImageView中添加了两个图像。我想在iPad方向纵向中显示image1.png
,并且想要在方向横向模式下显示image2.png
。任何人都可以请我建议如何在UIViewController
中通过Nib文件添加两个UIImageView?请为iPad笔尖文件提供任何教程。提前致谢。如何使用Nib文件在UIViewController中添加两个UIImageView?
0
A
回答
1
你必须改变的UIImageView的图像中的视图控制器的shouldAutorotate方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) && (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
// Set image in landscape mode
[imageView setImage:[UIImage imageNamed:@"image1.png"]];
}
else
// Set image in portrait mode
[imageView setImage:[UIImage imageNamed:@"image2.png"]];
}
}
我希望它能帮助你:)
1
刚刚从拖动的UIImageView图书馆并放入您的视野。 但是,如果您使用的是一个UIViewController和一个视图,则需要处理代码中的图像视图旋转更改。最简单的方法 - 显示/隐藏取决于方向。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
UIImageView *landscapeimageView = nil;
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)){
landscapeImageView.hidden = NO;
portretOmageView.hidden = YES;
}
else{
landscapeImageView.hidden = YES;
portretOmageView.hidden = NO;
}
}
您也可以只使用一个的UIImageView和image
属性更改为需要的图像:
[imageView setImage:[UIImage imageNamed:@"image1.png"]];//or @"image2.png"
相关问题
- 1. 在UIViewController中加载一个nib文件
- 2. 使用UIViewController加载nib文件
- 3. 使用另一个nib文件的nib文件加载视图
- 4. 在swift中从单独的nib文件加载UIViewController?
- 5. 如何在UIViewController中添加多个UITableView?
- 6. 如何在UIVIewController中添加多个UIAlertview?
- 7. 如何加载另一个nib文件?
- 8. 如何使用占位符从NIB加载UIViewController?
- 9. 如何在两个nib文件之间共享一个NSArrayController?
- 10. 我如何在splitviecontroller中加载两个不同类的nib文件?
- 11. 如何使用NSBundle加载几个nib文件loadNibNamed:?
- 12. 如何在MainView上添加UIView Nib文件作为子视图
- 13. 如何将自定义UIButton添加到XCode中的nib文件?
- 14. 如何将UIImageView添加到UIView(而不是UIViewController)?
- 15. 添加一个UIImageView作为一个UIViewController的子视图,而无需使用IB
- 16. 在Android中添加两个Mp3文件
- 17. 我可以在从NIB加载的UIImageView上使用DrawRect吗?
- 18. 如何在一个tableView上使用UIScrollViewDelegate方法添加到UIViewController?
- 19. 在nib中加载nib时,为什么awakeFromNib被调用两次?
- 20. 如何在UIViewController中添加UINavigationBar?
- 21. 如何添加两个index.php文件在.htaccess文件笨
- 22. 如何在另一个NIB的视图中加载NIB?
- 23. 使用两个星号在git中添加文件
- 24. 中添加和一个UIViewController
- 25. 使用NSViewController加载nib之后...如何访问nib中的NSButton?
- 26. iPhone:如何在一个NIB文件中创建两个控制器?
- 27. 如何在wxpython中并排添加两个文本控件
- 28. 如何将UISearchBar添加到同一个UIViewController中的两个TableView中
- 29. 在swift中添加没有nib文件的UIViewControllers到UITabBarController
- 30. 如何使用UIImageView附加邮件?
Dont't忘记在结束 – 2012-01-12 14:31:47
其真正返回YES!谢谢 :) – damacri86 2012-01-16 12:05:11