我正在開發支持橫向和縱向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. IOS縱向和橫向模式
- 5. UIScrollView在橫向和縱向模式下的zoomscale
- 6. 在橫向和縱向模式下啓動iPad應用程序
- 7. 在縱向和橫向模式下運行espresso androidTest s
- 8. 在橫向和縱向模式下使用ScrollViewer正確滾動
- 9. Android相機在縱向和橫向模式下保存圖像
- 10. UISplitViewController出現在橫向模式縱向
- 11. Libreoffice Writer:縱向模式下的文本和橫向模式下的表格
- 12. 導航欄不在iPad上摺疊縱向和橫向
- 13. UIScrollView在縱向模式和橫向模式下的行爲不同
- 14. 1日的ViewController在縱向和SecondViewController在橫向模式
- 15. 藍牙在縱向/橫向模式下斷開
- 16. UIViewcontroller在橫向模式下保持縱向座標
- 17. Android SCREEN_ORIENTATION_PORTRAIT僅在橫向模式下顯示縱向視圖
- 18. 如何在橫向模式下轉換導航欄和導航控制器
- 19. NavigationController橫向和縱向
- 20. 縱向和橫向滑動
- 21. 縱向和橫向居中
- 22. 如何知道橫向或縱向模式下的照片?
- 23. 爲uitableviewcells加載橫向和縱向xib文件的最佳方式是什麼?
- 24. 引導程序崩潰導航欄按鈕在橫向但不是縱向模式下工作
- 25. 使用片段在橫向和縱向模式之間切換
- 26. iPad的:問題在橫向和縱向
- 27. 如何在橫向和縱向模式下開始相同的活動?
- 28. 的XCode:如何更改的橫向和縱向模式
- 29. 從縱向模式到iOS5,iOS6的橫向模式
- 30. ImageView在橫向模式下
感謝nitish的詳細答案。它類似於iAmitwagh精神超過 – amavi 2011-06-08 11:31:31
是的。但我之前發佈它:) – Nitish 2011-06-08 11:33:37