相关疑难解决方法(0)

使用Objective-C中的类别覆盖方法

我可以使用类类别来覆盖已使用类别实现的方法吗?像这样:

1)原始方法

-(BOOL) method {
  return true;
}
Run Code Online (Sandbox Code Playgroud)

2)覆盖方法

-(BOOL) method {
  NSLog(@"error?"); 
  return true; 
}
Run Code Online (Sandbox Code Playgroud)

这会起作用,还是非法的?

objective-c categories

87
推荐指数
3
解决办法
5万
查看次数

iOS:AVPlayerViewController在纵向应用程序中启用全屏旋转

我有一个UIViewcontroller,它包含一个带AVPlayer的AVPlayerViewController.我想为AVPlayerViewController启用旋转(当视频在全屏时)并禁用UIViewController的任何旋转.如何在我的应用中为视频(全屏)启用旋转?

fullscreen avfoundation ios avplayer avplayerviewcontroller

13
推荐指数
1
解决办法
5615
查看次数

自动旋转在iOS 7中无法正常工作,在iOS 6中运行良好

我有一个应用程序仅支持某些部分(照片库,视频等)的横向方向,并且所有在iOS 6上运行良好没有问题,但是,在iOS 7中应用程序崩溃.

所以继承我的问题:

  1. 使用仅支持肖像的视图控制器启动应用程序并加载初始导航控制器
  2. 将视图控制器推送到支持横向和纵向的堆栈
  3. 将视图旋转到横向
  4. 弹出视图控制器
  5. 应用程序崩溃
-->
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:]
Run Code Online (Sandbox Code Playgroud)

+ 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 …

iphone orientation ios ios6 ios7

7
推荐指数
1
解决办法
8512
查看次数