无法确定UIImageView框架何时相等 [英] Cannot determine when UIImageView frames are equal

查看:217
本文介绍了无法确定UIImageView框架何时相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两层.底层由隐藏的UIImageView组成,顶层由可见的UIImageView组成.当底层UIImageView的所有帧都等于上层UIImageView s的帧时,您必须在NSLog中看到它.

I have two layers. The bottom layer consists of hidden UIImageViews, the upper layer consists of visible UIImageViews. When all the frames of the bottom layer UIImageViews are equal to the frames of the upper layer UIImageViews, you have to see that in a NSLog.

问题在于,由NSTimer调用的布尔方法总是立即返回true,因此我看到了NSLog.我只想在所有对应的帧都相等时看到NSLog.

The problem is that the boolean method which is called by a NSTimer always returns true immediately, so I see the NSLog. I only want to see the NSLog when all corresponding frames are equal to each other.

这是我的代码:

- (void)checkTheFrames {
    BOOL allEquals = [self isEqualFrames];
    if (allEquals) {
        NSLog(@"ALL THE FRAMES ARE EQUAL");
        [AllPosCorrectTimer invalidate];
    }
}

-(BOOL)isEqualFrames {
    for(int i = 0; i < arrayImg.count; i++ ){
        UIImageView *ImageView1 = arrayImg[i];
        UIImageView *ImageView2 = HiddenFieldView[i];
        if (!CGRectEqualToRect(ImageView1.frame, ImageView2.frame)) {
            return NO;
        }
    }
    return YES;
}

有没有办法解决这个问题?

Is there a way to solve this issue?

推荐答案

我认为这是错误的,因为您也正在比较Xs和Ys……也许您应该进一步研究frame.size并对其进行比较.或者也许容易地比较宽度和高度(frame1.size.width == frame2.size.width)

I think whats wrong is that you're comparing the Xs and Ys too... maybe you should go further to frame.size and compare them. Or maybe compare the widths and heights easily (frame1.size.width == frame2.size.width)

让我知道这是否不能解决问题!

Let me know if this didn't solve the problem!

这篇关于无法确定UIImageView框架何时相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆