Zer*_*ter 6 objective-c rotation ios ios8
嗨我有一个问题,在iOS8中旋转Modal呈现的ViewController.这一切在iOS7及更低版本上运行良好.
应用结构:
我的问题是当我提出模态控制器时旋转设备时,模态控制器的视图没有调整到景观框架.
看起来像这样:
调用了旋转方法,当我手动将视图的框架设置为横向时,右侧(屏幕灰色侧)的用户交互不起作用.
RootController代码:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
模态控制器代码:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if (self.presentingViewController != nil) {
[self.presentingViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation
duration:duration];
}
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if (self.presentingViewController != nil) {
[self.presentingViewController willRotateToInterfaceOrientation:toInterfaceOrientation
duration:duration];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if (self.presentingViewController != nil) {
[self.presentingViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
}];
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决iOS8的这个问题.
您如何呈现模态视图控制器?你为什么要自己转发轮换方法?如果做得正确,这应该会自动处理,您所需要的只是方法-supportedInterfaceOrientations(正如 Jasper 所说,autoresizingMask 或自动布局约束需要正确)。
| 归档时间: |
|
| 查看次数: |
973 次 |
| 最近记录: |