我正在開發支持橫向和縱向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