问题描述
我有两层.底层由隐藏的UIImageView
组成,顶层由可见的UIImageView
组成.当底层UIImageView
的所有帧都等于上层UIImageView
s的帧时,您必须在NSLog
中看到它.
I have two layers. The bottom layer consists of hidden UIImageView
s, the upper layer consists of visible UIImageView
s. When all the frames of the bottom layer UIImageView
s are equal to the frames of the upper layer UIImageView
s, 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框架何时相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!