0

いくつかのコンテナー (子) UIiewsController を持つ UIViewContoller があります。メインの UIViewController (mvc) には以下が含まれます。

  • 1.) mvc のビュー全体を占める UICollectionView (mvc.view の上にありますが、他のすべてのコントロールの下にあります)。
  • 2.) 検索オプションを表示する UIViewController (s1vc)
  • 3.) #2 (s2vc) に似た別のもの
  • 4.) #2 に似た別のもの (s3vc)

ここに画像の説明を入力

ジェスチャ認識機能を mvc に追加して、ユーザーが子ビュー コントローラーを画面からスワイプして非表示/表示できるようにしました。

問題は、ユーザーがいずれかのサービスを画面からスワイプすると、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 も切り替えようとしましたが、うまくいきませんでした。ファセットビューコントローラーがあった/ある場所をスワイプしてコレクションビューをスワイプすることはできません。

何か案は?

4

1 に答える 1

0

ここでの解決策は、parentViewController のコンテナー ビューに (IB を使用して) 別のアウトレットを追加し (このコードでは facetContainerView と呼びます)、それを userInteractionEnabled プロパティに設定することです。

-(void)hideFacets{
    if(self.facetVisible == NO) return;
    self.facetVisible = NO;

    [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;
                     }
                     completion:^(BOOL finished){
                         self.facetViewController.view.hidden = YES;
                         self.facetContainerView.userInteractionEnabled = NO;
                     }];
}

-(void)showFacets{
    if(self.facetVisible == YES) return;
    self.facetVisible = YES;
    self.facetContainerView.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;
                     }
                     completion:^(BOOL finished){         
                     }];
}

この新しいビュー アウトレットが self.facetViewController.view とどう違うのか興味があったので、このコードを挿入してアドレスを比較しました (実際には違います)。階層についてはよくわかりませんが、私が気付いていなかった余分なビューレイヤーがあるようです。

NSLog(@"self.facetViewController.view: %p", self.facetViewController.view);
NSLog(@"self.facetContainerView: %p", self.facetContainerView);

うまくいけば、これはある時点で誰かを助けるでしょう。

于 2013-04-17T22:37:51.433 に答える