如何从IBOutletCollection数组

时间:2015-05-14 09:37:08

标签: ios objective-c xcode iboutletcollection

我需要从IBOutletCollection数组中访问随机元素。我有4个字母的imageViews需要被拖到另一个imageView并根据拖动的数量更改图像。我正在测试2。我有这个,但它似乎不是随机的,而是4中的特定一个。

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{

    for (UIImageView *letter in letterA)
    {
        for (UIImageView *letter1 in letterA)
        {
            if (CGRectIntersectsRect(letter.frame ,answerA.frame))
            {
                UIImage *Pic1 = [UIImage imageNamed:@"number1"];
                [correctCounterA setImage:Pic1];
                letter.userInteractionEnabled=NO;
                letter.hidden=YES;

            }
            else if (CGRectIntersectsRect(letter1.frame, answerA.frame)) //CGRectIntersectsRect(letter.frame, answerA.frame))
            {
                UIImage *Pic2 = [UIImage imageNamed:@"number2"];
                [correctCounterA setImage:Pic2];
            }
        }

    }
}

0 个答案:

没有答案