使用SWRevealViewController时,我不想让用户与打开侧边菜单的视图进行交互。侧面菜单打开后,我希望能够与该菜单视图进行交互而不是另一个菜单视图。
任何帮助?
答案 0 :(得分:2)
我一直在/在SWRevealViewController上工作
所以你需要的是将你的frontViewController添加为SWRevealViewControllerDelegate
,然后实现这个功能
func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition)
当frontViewController
转到左侧或前方位置时,您会收到通知
这是Swift代码
在你的frontViewController中你需要添加
class FrontViewController: UIViewController, SWRevealViewControllerDelegate
{
override func viewDidLoad() {
super.viewDidLoad()
self.revealViewController().delegate = self;
}
// 您的代码 //
func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition) {
if(position == FrontViewPosition.Left)
{
self.view.userInteractionEnabled = true;
self.navigationController?.navigationBar.userInteractionEnabled = true;
}else
{
self.view.userInteractionEnabled = false;
self.navigationController?.navigationBar.userInteractionEnabled = false;
}
}
<强> // EDITED 强>
这是Objective C代码
class FrontViewController: UIViewController <SWRevealViewControllerDelegate>
在viewDidLoad中你需要添加
- (void)viewDidLoad
{
[super viewDidLoad];
self.revealViewController.delegate = self;
}
// 您的代码 //
- (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position
{
if(position == FrontViewPositionLeft)
{
self.view.userInteractionEnabled = NO;
self.navigationController.navigationBar.userInteractionEnabled = NO;
}else{
self.view.userInteractionEnabled = YES;
self.navigationController.navigationBar.userInteractionEnabled = YES;
}
}
我希望这可以帮到你