我可以使用类类别来覆盖已使用类别实现的方法吗?像这样:
1)原始方法
-(BOOL) method {
return true;
}
Run Code Online (Sandbox Code Playgroud)
2)覆盖方法
-(BOOL) method {
NSLog(@"error?");
return true;
}
Run Code Online (Sandbox Code Playgroud)
这会起作用,还是非法的?
我有一个UIViewcontroller,它包含一个带AVPlayer的AVPlayerViewController.我想为AVPlayerViewController启用旋转(当视频在全屏时)并禁用UIViewController的任何旋转.如何在我的应用中为视频(全屏)启用旋转?
我有一个应用程序仅支持某些部分(照片库,视频等)的横向方向,并且所有在iOS 6上运行良好没有问题,但是,在iOS 7中应用程序崩溃.
所以继承我的问题:
Run Code Online (Sandbox Code Playgroud)--> CRASH: **preferredInterfaceOrientationForPresentation must return a supported interface orientation!** 2013-11-06 10:18:06.220 ausopen-iphone-2014[57605:70b] Stack Trace: ( 0 CoreFoundation 0x03f665e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x03ce38b6 objc_exception_throw + 44 2 CoreFoundation 0x03f663bb +[NSException raise:format:] + 139 3 UIKit 0x01366f1c -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:]+ 580
其他信息:
在我的info.plist中,我支持肖像和风景
在我的AppDelegate中,我实现了以下方法:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{}
Run Code Online (Sandbox Code Playgroud)
在这个方法中,我指定如果第一个视图(HomeVC)显示它应该支持所有方向.
在这个方法中,我还指定如果第二个视图(PhotoVC)显示它也应该支持所有方向.
在我的第一个视图(HomeVC)中,我使用以下方法覆盖此方法,以便在显示视图时仅支持纵向模式:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
不确定iOS …
ios ×2
avfoundation ×1
avplayer ×1
categories ×1
fullscreen ×1
ios6 ×1
ios7 ×1
iphone ×1
objective-c ×1
orientation ×1