SWRevealViewController - 防止与后视图交互
SWRevealViewController - Prevent Interacting With The Back View
在使用 SWRevealViewController 时,我不想让用户与打开侧边菜单的视图进行交互。打开侧边菜单后,我只想与该菜单视图交互,而不是另一个。
有什么帮助吗?
好吧,我已经工作 with/on 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;
}
}
希望对你有所帮助
在使用 SWRevealViewController 时,我不想让用户与打开侧边菜单的视图进行交互。打开侧边菜单后,我只想与该菜单视图交互,而不是另一个。
有什么帮助吗?
好吧,我已经工作 with/on 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;
}
}
希望对你有所帮助