相关疑难解决方法(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万
查看次数

shouldAutorotateToInterfaceOrientation未在iOS 6中调用

我正在使用MGSplitViewController,我shouldAutorotateToInterfaceOrientation用来控制旋转时主视图控制器的大小.

它在iOS 5上运行良好,但在iOS 6(模拟器和iPad)shouldAutorotateToInterfaceOrientation上从未调用过.

这是一个我应该期望在iOS 6的最终版本中修复的错误或者我不知道已经改变的东西吗?

orientation ios ios6

61
推荐指数
8
解决办法
9万
查看次数

如何在仅限肖像的应用程序中使用MPMovieViewController播放风景视频

我的应用程序支持的界面方向是纵向和上下颠倒.但是,播放视频时,我希望它能够播放全屏风景.目前使用此代码,即使设备旋转,它也只播放肖像:

[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self presentMoviePlayerViewControllerAnimated:player];
Run Code Online (Sandbox Code Playgroud)

如何强制它进入横向模式?

mpmovieplayercontroller uiinterfaceorientation ios

6
推荐指数
1
解决办法
4969
查看次数

仅允许在一个视图控制器上进行自动旋转

在我的项目中,我只允许纵向旋转,但对于一个ViewController我想启用景观.我提出这个ViewController因为ModalViewController,我已经使用方法试过- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation或iOS 6的方法,如-(NSUInteger) supportedInterfaceOrientations,但没有实际工作.虽然这些方法被调用,但视图没有旋转.

在此之后,我试图通过听取这些通知的myslef来旋转它:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(didRotate:)
                                             name:UIDeviceOrientationDidChangeNotification
                                           object:nil];
Run Code Online (Sandbox Code Playgroud)

但即使我能够手动旋转viewin方法didRotate:它非常凌乱,我无法旋转StatusBar.

我真的很想使用标准方法shouldAutorotateToInterfaceOrientation,但我不知道如何.任何人?

objective-c uiviewcontroller ios

5
推荐指数
2
解决办法
8489
查看次数

在UIViewController上启用接口方向

可能重复:
shouldAutorotateToInterfaceOrientation在iOS 6中不起作用

我正在使用xcode 4.5,我只需要在一个包含webview的viewController上启用接口方向.我该如何启用它.

- (BOOL)shouldAutorotateToInterfaceOrientation 似乎在iOS6中已弃用

iphone uiwebview uiinterfaceorientation ios

0
推荐指数
1
解决办法
277
查看次数