在“if语句”中调用方法会使UIImageView移动不稳定

时间:2014-10-23 20:24:31

标签: objective-c if-statement uiimageview uibutton touchesbegan

我不知道我遇到的问题是与if语句的执行或问题有关。我有随机图像的uiimageview,它出现在屏幕上后立即选择,向上动画。 uiimageView可以平滑地动画,但是当我调用任何方法或在" if语句中放入一些代码时#34;在下面,uiimageview开始不规律地动画......很奇怪!混乱!虽然代码执行得很好,但奇怪的动作会给调用的方法或代码提供第二次机会,我希望uiimageview能够在我调用方法时继续顺利移动。

我尝试使用按钮而不是touchesBegan和UIViewAnimationOptionAllowUserInteraction,但问题仍然存在。 imageViews位于容器中,因此它们会根据动画uiimageview显示的图像进行响应。

if ((touch.view == self.imageView1)
    && [UIImagePNGRepresentation(self.movingRectangle1.image) isEqualToData:UIImagePNGRepresentation(image_a)]
    && ([UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_b)]
        || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_c)]
        || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_d)]
        || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_e)]
        || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_f)])){

        // wierd movements happen when I call a method here
        NSLog(@"imageShape1 touched, correct view!");
    }
else if ((touch.view == self.imageView1)
         &&  ([UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_g)]
              || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_h)]
              || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_i)]
              || [UIImagePNGRepresentation(self.imageView1.image) isEqualToData:UIImagePNGRepresentation(image_j)])){

             NSLog(@"touched but Wrong view!");
         }

0 个答案:

没有答案