我有一个带有几个容器(子)UIiewsController 的 UIViewContoller。主 UIViewController (mvc) 包含:
- 1.) 占据整个 mvc 视图的 UICollectionView(它在 mvc.view 之上但在所有其他控件之下)。
- 2.) 显示搜索选项的 UIViewController (s1vc)
- 3.) 另一个类似于 #2 (s2vc)
- 4.) 另一个类似于 #2 (s3vc)
我在 mvc 中添加了手势识别器,以便用户可以通过将每个子视图控制器从屏幕上滑出来隐藏/显示它们。
问题是当用户从屏幕上滑出任何 svcs 时,他们无法滚动 mvc 的 collectionView。
这是我隐藏/显示 svcs 的方式:
-(void)swipeLeftGestureHandler:(UIGestureRecognizer*)gestureRecognizer{
SMLOG(@"Swiped Left");
if([SMUser activeUser] == nil) return;
if([self gestureHorizontalScreenSide:gestureRecognizer] == kHorizontalScreenSideLeft){
[self hideFacets];
}
else{
[self showAccordion];
}
}
-(void)swipeRightGestureHandler:(UIGestureRecognizer*)gestureRecognizer{
SMLOG(@"Swiped Right");
if([SMUser activeUser] == nil) return;
if([self gestureHorizontalScreenSide:gestureRecognizer] == kHorizontalScreenSideLeft){
[self showFacets];
}
else{
[self hideAccordion];
}
}
-(void)hideFacets{
if(self.facetVisible == NO) return;
[UIView animateWithDuration:0.25
animations:^{
CGRect newFrame = self.facetViewController.view.frame;
newFrame.origin = CGPointMake(newFrame.origin.x - newFrame.size.width, newFrame.origin.y);
self.facetViewController.view.frame = newFrame;
self.facetVisible = NO;
}
completion:^(BOOL finished){
self.facetViewController.view.hidden = YES;
self.facetViewController.view.userInteractionEnabled = NO;
}];
}
-(void)showFacets{
if([SMUser activeUser] == nil) return;
if(self.facetVisible == YES) return;
self.facetViewController.view.userInteractionEnabled = YES;
[UIView animateWithDuration:0.25
animations:^{
self.facetViewController.view.hidden = NO;
CGRect newFrame = self.facetViewController.view.frame;
newFrame.origin = CGPointMake(newFrame.origin.x + newFrame.size.width, newFrame.origin.y);
self.facetViewController.view.frame = newFrame;
self.facetVisible = YES;
}
completion:^(BOOL finished){
}];
}
如您所见,我正在切换 svc.view.hidden 属性,然后我也尝试切换 svc.userInteractionEnabled.property 但没有运气。仍然无法通过滑动构面视图控制器所在的位置来滑动集合视图。
有任何想法吗?