我正在开发支持横向和纵向orientation.I两个不同的笔尖文件为我的rootviewController iPad应用程序。以下是该问题的场景 -
1.在portait模式下从根视图中选择一个项目,以纵向推送下一个视图。
2.转动设备
3.按导航栏上的后退按钮
该视图从堆栈加载的是rootViewController的portait视图。设备仍处于横向模式。
请建议解决方案来处理上述问题。
另外,请在处理设备旋转时建议遵循的最佳做法。UINavigationController在横向和纵向模式下导航的最佳做法
回答
以下列方法使用通知,并设置receivedRotate方法中的坐标。
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
-(void)viewWillDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}
例如在receivedRotate你可以设置你的tableview的坐标为:
if (orientation == UIDeviceOrientationLandscapeLeft||orientation==UIDeviceOrientationLandscapeRight)
{
[tblView reloadData];
tableX=70.0;
}
else
{
[tblView reloadData];
tableX=48.0;
}
也叫recieveRotate在viewDidLoad中这是非常重要。
检查这种方法,可能会帮助ü...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (
interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown
);}
或尝试设置autoresizingMask的控制器希望这将有助于ü。
我回来是支持所有的旋转。你可以把一些光autoresizingMask?如何以及在哪里设置? – amavi 2011-06-08 09:56:27
其UIComponent的属性。你可以将它设置为UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight。它会根据方向自动调整UI组件的宽度和高度。 – 2011-06-08 09:58:48
您需要在运行时方法 检查方向 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
} &变化根据定向视图的元素。
感谢Amit.It协同实现 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation持续时间:(NSTimeInterval)持续时间方法来处理旋转。 – amavi 2011-06-08 11:30:47
- 1. 方向纵向和横向模式
- 2. 在UINavigationController中支持纵向和横向视图的最佳实践
- 3. 的UINavigationController的导航栏不会收缩时在横向模式
- 4. 在横向和纵向模式下使用ScrollViewer正确滚动
- 5. Android相机在纵向和横向模式下保存图像
- 6. 在纵向和横向模式下运行espresso androidTest s
- 7. 在横向和纵向模式下启动iPad应用程序
- 8. UIScrollView在纵向模式和横向模式下的行为不同
- 9. 蓝牙在纵向/横向模式下断开
- 10. 如何在横向模式下转换导航栏和导航控制器
- 11. NavigationController横向和纵向
- 12. 如何知道横向或纵向模式下的照片?
- 13. 引导程序崩溃导航栏按钮在横向但不是纵向模式下工作
- 14. 使用片段在横向和纵向模式之间切换
- 15. iPad的:问题在横向和纵向
- 16. 的XCode:如何更改的横向和纵向模式
- 17. 如何在横向模式而不是纵向模式下捕获avfoundation
- 18. Android的横向和纵向模式变化
- 19. 如何检查appdelegate上的横向和纵向模式?
- 20. 纵向和横向模式之间的过渡
- 21. 为纵向和横向模式调整UIImage的大小
- 22. iOs应用程序开发的纵向和横向模式
- 23. Nexus 7 - 用于纵向和横向模式的不同布局
- 24. 在纵向模式和横向模式之间切换表格的问题
- 25. 只需在纵向模式下的标签栏和在横向模式下的所有viewControllers
- 26. 复选框从纵向到横向模式的句柄方向
- 27. 以纵向和横向模式显示图像
- 28. Android:如何处理纵向反转纵向和横向反转横向事件
- 29. 如何更改纵向和横向的模拟器方向?
- 30. Xcode 4.2纵向和横向和对齐
感谢nitish的详细答案。它类似于iAmitwagh精神超过 – amavi 2011-06-08 11:31:31
是的。但我之前发布它:) – Nitish 2011-06-08 11:33:37