I have two UIViews, named Alice and Bob. Both have a fixed size. Alice's position in the superview is fixed using constraints. Bob is supposed to be dragged by the user until Bob intersects with Alice. However, a subsequent call to CGRectIntersectsRect does not necessarily return true even if Bob does intersect with Alice, which I've checked visually.
Here's my code:
Here's my code:
Code:
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3e1e81} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4f8187} p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px} p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12f1b} p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #31595d} span.s1 {font-variant-ligatures: no-common-ligatures} span.s2 {font-variant-ligatures: no-common-ligatures; color: #ba2da2} span.s3 {font-variant-ligatures: no-common-ligatures; color: #4f8187} span.s4 {font-variant-ligatures: no-common-ligatures; color: #703daa} span.s5 {font-variant-ligatures: no-common-ligatures; color: #3e1e81} span.s6 {font-variant-ligatures: no-common-ligatures; color: #d12f1b} span.s7 {font-variant-ligatures: no-common-ligatures; color: #000000} span.s8 {font-variant-ligatures: no-common-ligatures; color: #272ad8} span.s9 {font-variant-ligatures: no-common-ligatures; color: #31595d}
-(void)label:(DraggableLabel *)label newRect:(CGRect)rect
{
NSString *word = [NSString stringWithFormat:@"%@%@",[label text],wordFamilyName];
NSURL *firstLetterUrl = [[NSBundle mainBundle] URLForResource:[[label text] lowercaseString] withExtension:@"m4a" subdirectory:@"sounds"];
AVPlayerItem *wordSoundItem = [[AVPlayerItem alloc] initWithURL:wordSoundUrl];
AVPlayerItem *firstLetterSound = [[AVPlayerItem alloc] initWithURL:firstLetterUrl];
CGRect targetRect = [self.lastLettersLabel frame];
targetRect.size.height += 50;
targetRect.size.width += 50;
if (CGRectIntersectsRect([self.lastLettersLabel frame], rect))
{
/* [label setUserInteractionEnabled:false]; */
if ([word isEqualToString:correctString]) {
// Child built the word we want him to.
[label moveOnTopOfView:self.lastLettersLabel.rectangleView];
[[self textCollectionView] setUserInteractionEnabled:false];
labelDropped = label;
if ([[someEnumerator allObjects] count] == 0) {
// End of section.
[self newActivityUnlocked];
}
[[self queuePlayer] play];
}
else
{
@try {
[[self queuePlayer] insertItem:wordSoundItem afterItem:nil];
}
@catch (NSException *e)
{
NSLog(@"%@", [e reason]);
}
[[self queuePlayer] play];
}
}
else
{
}
}
Last edited: