iOS AutoLayOut UITapGestureRecognizer古怪

时间:2014-03-04 01:02:34

标签: ios uiview autolayout uitapgesturerecognizer

编程很新,所以我请你耐心等待。

我正在制作卡片匹配游戏。

我有20个UIViews作为子视图(Aka卡)添加到UIView超级视图(播放表面)。此superview具有应用于其的默认自动布局约束。我将UITapGestureRecognizers添加到所有20个子视图中。当手机处于拍摄状态时,水龙头会被识别,但在风景中,我的一半子视图停止识别水龙头(已解散的水龙头都在右侧 - 不知道是否有问题)。

感谢您的帮助

看图片 http://i62.tinypic.com/behjjr.png http://i60.tinypic.com/2cmt7jl.png

这就是我添加UITapGesture的方式:

-(NSMutableArray *)cardCollection{
    if (!_cardCollection) {
        _cardCollection=[[NSMutableArray alloc] init];

        for (int index=0; index<[self cardCount]; index++){

        Card *card=[self.game cardAtIndex:index];
        //[self addViewtoCardView: card];

        UIView *cardView;
        cardView=[self displayViewforContent:card];

        [cardView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]];

        cardView.layer.opaque=NO;

        //this adds to the nsmutablearray
        [self.cardCollection addObject:cardView];
    }
}
return _cardCollection;
}

1 个答案:

答案 0 :(得分:0)

视图是否以新方向拉伸?更改父视图的背景颜色以确保其他视图在其范围内。否则他们将不会接触到。如果要将它们添加到viewController的主视图中,请尝试添加。

self.view.autoresizingMask =  UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;