使用ImageView和touchesBegan制作图库的问题

时间:2015-03-15 18:30:27

标签: ios objective-c imageview

我正在尝试为我的iPhone应用创建图片库。我已经布局了imageViews,我希望它们在用户点击它们时增加大小,然后在它们发布时恢复正常。我制作的代码适用于第一张图片,但其余图片完全没有响应。即使我完全删除了第一个。

以下是我一直在尝试使用的代码,有没有人知道为什么它可能无法正常工作?

谢谢!

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch view] == _imageOne)
{
CGRect newFrame = _imageOne.frame;
newFrame.size.width += 280;
newFrame.size.height += 280;
_imageOne.frame = newFrame;
}
if ([touch view] == _imageTwo)
{
    CGRect newFrame2 = _imageTwo.frame;
    newFrame2.size.width += 280;
    newFrame2.size.height += 280;
    _imageTwo.frame = newFrame2;
}
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch view] == _imageOne)
{
    CGRect newFrame = _imageOne.frame;
    newFrame.size.width -= 280;
    newFrame.size.height -= 280;
    _imageOne.frame = newFrame;
}
if ([touch view] == _imageTwo)
{
    CGRect newFrame2 = _imageTwo.frame;
    newFrame2.size.width -= 280;
    newFrame2.size.height -= 280;
    _imageTwo.frame = newFrame2;
}
}

0 个答案:

没有答案