如何禁用前视图的交互,但如果我们点击前视图,则后视图应在swrevealview控制器中关闭

时间:2016-09-06 14:50:11

标签: ios objective-c swrevealviewcontroller

我在点击菜单后使用我想要的swreveal视图控制器然后如果我们点击前视图然后后面应该关闭我们应该无法与前视图交互。我使用以下代码禁用交互,但如果我们禁用交互,则点击guest虚拟机也将无效。

 - (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:    (FrontViewPosition)position {
if(position == FrontViewPositionLeft) {
    self.view.userInteractionEnabled = YES;
} else {
    self.view.userInteractionEnabled = NO;
}
}

- (void)revealController:(SWRevealViewController *)revealController didMoveToPosition:    (FrontViewPosition)position {
if(position == FrontViewPositionLeft) {
    self.view.userInteractionEnabled = YES;
} else {
    self.view.userInteractionEnabled = YES;
  hideFilter=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    hideFilter.backgroundColor=[UIColor blueColor];
    [self.view addSubview:hideFilter];

    SWRevealViewController *reveal = self.revealViewController;
    reveal.delegate = self;
    if ( reveal )
    {
        [hideFilter addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
        [hideFilter addGestureRecognizer:self.revealViewController.panGestureRecognizer];
    }
  }
}

我使用hidefilter来隐藏self.view中的交互并在其上添加一个gusture但是在点击它之后这个视图应该删除并交互主视图。那我该怎么做呢如果还有其他方法可以这样做,请告诉我 谢谢

1 个答案:

答案 0 :(得分:0)

听起来你说你希望顶视图允许点击(或手势)通过它到下面的视图。

如果是这样,这里有一些Stack Overflow答案可以帮助您:

How to send touch events to superview in iOS?

iOS - forward all touches through a view