在一次開發項目中遇到了播放視頻,播放完視頻回到列表,該列表在 NavigationController 裏面, NavigationController 放在了 UItabBarController 裏面,做旋轉禁止的操作,試了好多方法,在 UIViewController 寫禁止旋轉的方法,在 navigaitonController 類別裏面寫,都沒有很好地餓解決該旋轉的方法,都沒有解決該問題.
後來自定義了 UITabBarController的類別纔算解決了該旋轉的問題,
#import <UIKit/UIKit.h>
@interface UITabBarController (TabBarRotation)
- (BOOL)shouldAutorotate;
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
@end
#import "UITabBarController+Rotation.h"
@implementation UITabBarController (TabBarRotation)
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
@end
上面的一個類別可以解決 UITabBarController裏面出現的旋轉的問題,
bo