【发布时间】:2016-10-03 14:32:26
【问题描述】:
当使用 SWRevealViewController 时,我不想让用户与打开侧边菜单的视图交互。侧边菜单打开后,我希望能够与该菜单视图进行交互,而不是另一个。
有什么帮助吗?
【问题讨论】:
标签: ios objective-c swift swrevealviewcontroller
当使用 SWRevealViewController 时,我不想让用户与打开侧边菜单的视图交互。侧边菜单打开后,我希望能够与该菜单视图进行交互,而不是另一个。
有什么帮助吗?
【问题讨论】:
标签: ios objective-c swift swrevealviewcontroller
好吧,我已经在 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;
}
}
//已编辑
这是 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;
}
}
希望对你有帮助
【讨论】: