1

此代码循环通过将子视图添加到当前子视图(这是一个纸牌游戏)...

        //Creates the Card's view and adds it to the cardContainerView
        CardView *cardView = [[CardView alloc]initWithFrame:CGRectMake(0, 0, 67,99)];
        [cardContainerView addSubview:cardView];


        //Assign the UIGesture to the CardView

        //For panning and dragging
        UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePanGesture:)];
        [cardView addGestureRecognizer:panGesture];

...一旦交易完成,我想用触摸手势选择一张卡片并拖动它 - 在这个序列中,我希望这张卡片悬停在所有其他卡片上(比如在纸牌中,你想从一张卡片中添加一张卡片列到另一个)

4

1 回答 1

0

我认为你需要做的就是这样的:

在handlePanGesture中:

- (void)handlePanGesture:(UIGestureRecognizer *)recognizer {

    UIView *touchedView = recognizer.view;
    [touchedView.superview bringSubviewToFront:touchedView];
    ... // Rest of your code here.
}

如果touchedView.superview不起作用,您可能需要考虑使 cardContainerView 成为您的类的属性并在您的handlePanGesture:方法中访问它。

于 2013-02-03T04:23:45.310 回答