gpt4 book ai didi

ios - 使用 MMDrawerConroller 如何禁用旋转是一些 ViewControllers?

转载 作者:可可西里 更新时间:2023-11-01 04:34:21 27 4
gpt4 key购买 nike

我在来自 this 的应用程序中使用 MMDrawerController链接
我以这种方式在 AppDelegate 中设置根 ViewController:

    self.leftDrawerController = [[LeftDrawerViewController alloc] init];

self.homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.homeViewController];

// DrawerViewController setup
self.drawerController = [[MMDrawerController alloc]
initWithCenterViewController:self.navigationController
leftDrawerViewController:self.leftDrawerController];
[self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

[self.drawerController setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block; block = [[DrawerVisualStateManager sharedManager] drawerVisualStateBlockForDrawerSide:drawerSide];
if (block) {
block(drawerController, drawerSide, percentVisible);
}
}];

[self.window setRootViewController:self.drawerController];

我想在特定的 ViewController 中禁用旋转,我正在调用这些方法,但它们从未被调用, View 仍在旋转:

//  ViewController.m

-(BOOL)shouldAutorotate {
return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

我猜问题出在 rootViewController,也就是 MMDrawerViewController!
我已经查过了 thisthisthis但没有任何帮助。

最佳答案

如果问题仍然存在,那么继承 UINavigationController 并实现

-(BOOL)shouldAutorotate {            
return [self.topViewController shouldAutorotate];
}

- (NSUInteger)supportedInterfaceOrientations {
return [self.topViewController supportedInterfaceOrientations];
}

我认为 UINavigationController 会自动控制,但如果它不能控制,您可以子类化。

关于ios - 使用 MMDrawerConroller 如何禁用旋转是一些 ViewControllers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28876294/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com