我可以使用类类别来覆盖已使用类别实现的方法吗?像这样:
1)原始方法
-(BOOL) method {
return true;
}
Run Code Online (Sandbox Code Playgroud)
2)覆盖方法
-(BOOL) method {
NSLog(@"error?");
return true;
}
Run Code Online (Sandbox Code Playgroud)
这会起作用,还是非法的?
我正在使用MGSplitViewController,我shouldAutorotateToInterfaceOrientation用来控制旋转时主视图控制器的大小.
它在iOS 5上运行良好,但在iOS 6(模拟器和iPad)shouldAutorotateToInterfaceOrientation上从未调用过.
这是一个我应该期望在iOS 6的最终版本中修复的错误或者我不知道已经改变的东西吗?
我的应用程序支持的界面方向是纵向和上下颠倒.但是,播放视频时,我希望它能够播放全屏风景.目前使用此代码,即使设备旋转,它也只播放肖像:
[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self presentMoviePlayerViewControllerAnimated:player];
Run Code Online (Sandbox Code Playgroud)
如何强制它进入横向模式?
在我的项目中,我只允许纵向旋转,但对于一个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,但我不知道如何.任何人?
我正在使用xcode 4.5,我只需要在一个包含webview的viewController上启用接口方向.我该如何启用它.
- (BOOL)shouldAutorotateToInterfaceOrientation 似乎在iOS6中已弃用