是这样的 我只想专门做一个可以横屏播放视频的controller 有人知道怎么弄吗 我已经写好代码 只有横屏没实现了 如果可以 你可以运行一下我的代码 我把.h .m发给你,实现横屏 不要说把project里面的landspace 勾选 我只想用代码控制横屏 谢谢
PHP中文网2017-04-17 17:36:58
This question is quite similar to https://segmentfault.com/q/1010000004486783/a-1020000004487227. I moved my answer here:
Add the shouldAutorotate
method in ViewController. The logic inside is roughly as follows:
@implementation ViewController
- (BOOL)shouldAutorotate {
int32_t i = 1;
if (i == 1) {
return NO;
}
return YES;
}
@end
If your ViewController is managed in UINavigationController, you need to modify the corresponding behavior of UINavigationController. For example, the implementation idea through Category is roughly as follows:
#import "UINavigationController.h"
@implementation UINavigationController (Overrides)
- (BOOL)shouldAutorotate {
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[<#your-vc#> class]]) {
int32_t i = 1;
if (i == 1) {
return NO;
}
return YES;
}
return YES;
}
@end