gpt4 book ai didi

ios - 在 UIView beginAnimations 完成后做一个 Action

转载 作者:行者123 更新时间:2023-11-29 00:45:03 24 4
gpt4 key购买 nike

我想在 UIView 动画完成后做一个 Action 。

    if (flipStateHav1 == 1 && btnFrontHav1.tag == 1) {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:buttonContainerHav1 cache:YES];
[self.buttonContainerHav1 bringSubviewToFront:btnBackHav1];

[UIView commitAnimations];

//It is this code below I want to run after the animation is finish.
buttonContainerHav1.userInteractionEnabled = YES;
flipTurns = 0;
flipStateHav2 = 0;
par = 0;
}

我试过用

    completion:^(BOOL finished){
// your code
}];

但不要让它工作,可能是我做错了什么。

更新代码该按钮连接到两个操作。

- (IBAction) buttonPressedFlipHav1 {

if (flipTurns == 0 || flipTurns == 1) {

flipTurns += 1;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:buttonContainerHav1 cache:YES];
[self.buttonContainerHav1 bringSubviewToFront:btnFrontHav1];
buttonContainerHav1.userInteractionEnabled = NO;
flipStateHav1 = 1;
btnFrontHav1.tag = 1;

autoFlipCount += 1;

if (flipStateHav1 == 1 && flipStateHav2 == 1) {
par = 1;
parHav = 1;
btnFrontHav1.tag = 0;
btnFrontHav2.tag = 0;

flipTurns = 0;
autoFlipCount = 0;

if (parHav == 1 && parRiddare == 1 && parSkold == 1) {

autoFlipTimer = [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(autoFlipAll) userInfo:nil repeats:NO];

}
}

} completion:^(BOOL finished) {

NSLog(@"autoFlipCount = %d",autoFlipCount);
NSLog(@"Flipturns = %d",flipTurns);
}];

}

}

而且它也和这个 Action 有关。

- (IBAction) autoFlip {
autoFlipTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(callAfterFiveSecond) userInfo:nil repeats:NO];
}

5 秒后它跳转到这个 if 语句。 已更新

if (flipStateHav1 == 1 && btnFrontHav1.tag == 1) {

[UIView animateWithDuration:0.8 animations:^{

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:buttonContainerHav1 cache:YES];
[self.buttonContainerHav1 bringSubviewToFront:btnBackHav1];

} completion:^(BOOL finished) {
buttonContainerHav1.userInteractionEnabled = YES;
flipTurns = 0;
flipStateHav1 = 0;
par = 0;
}];

}

最佳答案

这段代码可能对你有帮助

[UIView animateWithDuration:0.4 animations:^{
//animation code here`
} completion:^(BOOL finished) {
//code after animation here
}];

关于ios - 在 UIView beginAnimations 完成后做一个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38716048/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com