I have looked at UIButton can't be touched while animated with UIView animateWithDuration and the answer doesn't help me.
for (UIButton *button in self.buttonsOutletCollection)
This part is the one that is confusing. My button isn't part of a IBOutletCollection so this doesn't work. I use this to move the button:
- (void) squareOneMover {
CGRect oldFrame = _squareOne.frame;
[UIView animateWithDuration:2
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
CGRect newFrame = CGRectMake(oldFrame.origin.x , oldFrame.origin.y + 500, oldFrame.size.width, oldFrame.size.height);
_squareOne.frame = newFrame;
}
completion:nil
];
}
I don't want to have to move the Button in small amounts because I need five buttons and it would be inefficient.
Can someone provide me with an answer similar to the question above that is for UIButtons
not include in any array?
Edit:
The UIButton
is defined in the interface file and connected to Interface Builder, and is strong
and nonamatic
Edit 2: I am now using animateWithDuration:delay:options:animations:completion:
but it still doesn't work.
I use this code to detect if the button is being pressed.
- (void)squareOnePressed:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
if ([self.squareOne.layer.presentationLayer hitTest:touchLocation])
{
NSLog(@"YO");
}
}
But when the button is pressed nothing still happens... So how do I program that ^^^^