我正在尝试禁用iOS中的单个viewController的旋转,我已经看到一些问题要求自动旋转但是没有。
我想锁定View B打开的方向。例如:在横向打开,它只能是横向,或以纵向打开,它只能是纵向。同时仍然允许视图A成为它想要的任何方向。
修改 \ n 这就是我称之为视图B
的方式 [self.mediaFocusController showImageFromURL:url fromView:self.view withThumb:thumbUrl];
这是它进入的方式:
if (self.targetViewController) {
[self willMoveToParentViewController:self.targetViewController];
if ([UIView instancesRespondToSelector:@selector(setTintAdjustmentMode:)]) {
self.targetViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
[self.targetViewController.view tintColorDidChange];
}
[self.targetViewController addChildViewController:self];
[self.targetViewController.view addSubview:self.view];
if (self.snapshotView) {
[self.targetViewController.view insertSubview:self.snapshotView belowSubview:self.view];
[self.targetViewController.view insertSubview:self.blurredSnapshotView aboveSubview:self.snapshotView];
}
}
else {
// add this view to the main window if no targetViewController was set
if ([UIView instancesRespondToSelector:@selector(setTintAdjustmentMode:)]) {
self.keyWindow.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
[self.keyWindow tintColorDidChange];
}
[self.keyWindow addSubview:self.view];
if (self.snapshotView) {
[self.keyWindow insertSubview:self.snapshotView belowSubview:self.view];
[self.keyWindow insertSubview:self.blurredSnapshotView aboveSubview:self.snapshotView];
}
}
我设置了NavigationController,但这个视图不同
答案 0 :(得分:0)
尝试此代码(我在https://stackoverflow.com/a/17377221/2040992中找到):
- (BOOL)shouldAutorotate
{
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[DetailViewController class]])
return NO;
return YES;
}