當按鈕移動時,我無法進行按鈕操作。 任何人都可以幫助我如何在點擊時隱藏移動按鈕? 當我點擊按鈕時沒有反應。 下面的代碼:如果你想隱藏它的任何觸摸事件使用UIViewAnimation移動時xcode tap按鈕
- (void) turtleTouched: (id) sender
{
UIButton *button = sender; // Typecast sender
button.hidden = YES;
}
,使用以下命令::
-(void)createTurtle
{
NSUInteger r = arc4random_uniform(284) + 1;
NSUInteger randomTitle = arc4random_uniform(1000000) + 1;
turtle = [[UIButton alloc] init];
turtle.frame = CGRectMake(r, 0, 36, 47);
[turtle setImage:[UIImage imageNamed:@"turtle.png"] forState:UIControlStateNormal];
[turtle addTarget:self action:@selector(turtleTouched:) forControlEvents:UIControlEventTouchDown];
[turtle setTitle:[NSString stringWithFormat:@"%lu", (unsigned long)randomTitle] forState:UIControlStateNormal];
[turtle setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self.view bringSubviewToFront:turtle];
[self.view addSubview:turtle];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:16];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
turtle.frame = CGRectMake(turtle.frame.origin.x, self.view.frame.size.height, 36, 47);
[UIView commitAnimations];
}
- (void) turtleTouched: (id) sender
{
UIButton *button = sender; // Typecast sender
button.hidden = YES;
}
感謝你的答案工作!謝謝! –
這是它!非常感謝你!它工作得很好! –