【发布时间】:2023-04-06 22:49:02
【问题描述】:
我有一个 MainViewController,它有一个按钮 init。在按钮上单击图片开始动画,然后我创建一个不同 ViewController 的新实例,该实例运行 Web 请求并提取一些信息并将其推送到前面。我希望在中间视图控制器运行时图像是动画的。最后,一旦 MiddleViewController 完成,在同一个按钮方法中,我切换到第三个 ViewController。正如预期的那样,我收到以下错误:
Warning: Attempt to present <ThirdViewController: 0x962b470> on <MainViewController: 0x986c200> while a presentation is in progress!
Unbalanced calls to begin/end appearance transitions
我该如何解决这个问题?我宁愿不移除中间的 ViewController 并将其代码集成到 MainViewController 中。
-(void)singleTapping:(UIGestureRecognizer *)recognizer
{
UIImage *rot1 = [UIImage imageNamed:@"pic1.png"];
UIImage *rot2 = [UIImage imageNamed:@"pic2.png"];
UIImage *rot3 = [UIImage imageNamed:@"pic3.png"];
UIImage *rot4 = [UIImage imageNamed:@"pic4.png"];
self.scanclickedimage.animationImages = [[NSArray alloc] initWithObjects:rot1, rot2, rot3, rot4, nil];
self.scanclickedimage.animationDuration = 0.6f;
self.scanclickedimage.animationRepeatCount = HUGE_VALF;
[self.scanclickedimage startAnimating];
if (nextString == NULL || [nextString isEqualToString:@""]) {
NSLog(@"Initializing MiddleViewController");
MiddleViewController * middleViewController = [[MiddleViewController alloc] init];
middleViewController.delegate = self;
[self presentViewController:middleViewController animated:YES completion:nil];
} else {
ProductWebRequest *request = [[ProductWebRequest alloc] init];
[request sendWebRequest:nextString];
}
NSString * storyboardName = @"MainStoryboard";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ThirdViewController"];
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:vc animated:YES completion:nil];
}
【问题讨论】:
标签: ios view viewcontroller