的選項卡時,只能旋轉的一些看法這裏是我無法弄清楚如何工作的流程。 (當我聲明(工作)時,這意味着在當前狀態下,該視圖的方向規則正常工作)我如何與一個UINavigationController工作作爲一個的UITabBarController
第一次查看:UITabBarController的選項卡的UINavigationController的堆棧上的TableView。
TableView只允許爲肖像。 (working) 當您將TableView旋轉到橫向模式時,會出現一個類似於coverflow的自定義UIView(我將在稍後解釋該問題)。
甲選擇上的tableview由上推到堆棧一個UIScrollView。
UIScrollView的是允許所有方向。 (工作)
當UIScrollView的是在橫向模式和用戶打回他們被帶到了自定義的UIView是喜歡的CoverFlow和只允許景觀。
問題在這裏。由於UIScrollView允許完整旋轉,因此它允許TableView旋轉以及橫向旋轉。
我有一個方法附加到通知「UIDeviceOrientationDidChangeNotification」,檢查自定義視圖是否是當前控制器,如果是,並且用戶已經旋轉回肖像我需要彈出自定義視圖並顯示錶視圖。
表視圖有轉回肖像,這確實是好的,只要用戶不會看到它。當我創建自定義動畫時,除了一些奇怪的看不見的黑盒子,它似乎隨着設備旋轉之前,我淡出自定義視圖到桌面視圖非常好。
此外,爲了確保我的tableview將旋轉到縱向,我必須允許customview支持所有方向,因爲系統查看當前視圖(在我的代碼中)是否允許該應用旋轉到一定的方向。正因爲如此,我提出的許多解決方案將在桌面視圖重新聚焦時顯示自定義視圖旋轉到縱向。
我的其他問題非常相似。如果您正在查看tableview並旋轉customview的模態視圖。在此視圖上進行選擇時,它會將UIScrollview推入堆棧,但由於Tableview僅支持縱向,所以在設備處於橫向模式時,UIScrollview以縱向顯示。
我該如何克服這些可怕的塊?
這是我目前的嘗試:
當談到與工作的UITabBarController系統真的只關心什麼tabbarcontroller不得不說的旋轉。
目前無論何時報告一個視圖加載它支持的方向。
TabBarController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
switch (self.supportedOrientation) {
case SupportPortraitOrientation:
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
return (interfaceOrientation == UIInterfaceOrientationPortrait);
break;
case SupportPortraitUpsideDownOrientation:
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
break;
case SupportPortraitAllOrientation:
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
break;
case SupportLandscapeLeftOrientation:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
break;
case SupportLandscapeRightOrienation:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
break;
case SupportLandscapeAllOrientation:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
break;
case SupportAllOrientation:
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
}else {
//[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
}
return YES;
break;
default:
return (interfaceOrientation == UIInterfaceOrientationPortrait);
break;
}
}
的代碼塊是我的UINavigationController的一部分,並且是在響應該通知UIDeviceOrientationDidChangeNotification的方法。它負責彈出customview並顯示tableview。有兩種不同的版本,最初是針對兩種不同版本的SDK,但兩者都非常接近解決方案。
第一個在3.0上不支持的原因是由於某些原因,您無法將視圖顯示並顯示爲模式視圖。不知道這是一個錯誤還是一個功能。
第二種解決方案工作得非常好,除了我看到一個圍繞iphone旋轉的外框。
if ([[self topViewController] isKindOfClass:FlowViewController.class]) {
NSString *iphoneVersion = [[UIDevice currentDevice] systemVersion];
double version = [iphoneVersion doubleValue];
if(version > 3.0){ //1st solution
//if the delivered app is not built with the 3.1 SDK I don't think this will happen anyway
//we need to test this
[self presentModalViewController:self.flowViewController animated:NO];
//[self toInterfaceOrientation:UIDeviceOrientationPortrait animated:NO];
[self popViewControllerAnimated:NO];
[self setNavigationBarHidden:NO animated:NO];
[self dismissModalViewControllerAnimated:YES];
}else{ //2nd solution
DLog(@"3.0!!");
//[self toInterfaceOrientation:UIDeviceOrientationPortrait animated:NO];
CATransition *transition = [CATransition animation];
transition.duration = 0.50;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFade;
CATransition *tabBarControllerLayer = [CATransition animation];
tabBarControllerLayer.duration = 0.50;
tabBarControllerLayer.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
tabBarControllerLayer.type = kCATransitionPush;
tabBarControllerLayer.subtype = kCATransitionFade;
[self.tabBarController.view.layer addAnimation:transition forKey:kCATransition];
[self.view.layer addAnimation:transition forKey:kCATransition];
[self popViewControllerAnimated:NO];
[self setNavigationBarHidden:NO animated:NO];
}
[self performSelector:@selector(resetFlow) withObject:nil afterDelay:0.75];
}
我接近確信沒有解決方案,除了手動旋轉,這弄亂了鍵盤旋轉。
任何意見將不勝感激!
謝謝。