我希望在动画完成后运行一段代码,但编译器显示以下错误:“不兼容的块指针类型向’void(^)(BOOL)’类型的参数发送’void(^)(void)’”
这是我的代码,我不确定我做错了什么,请帮助,谢谢.
[UIView transitionWithView:self.view duration:1.5 options:UIViewAnimationOptionTransitionFlipFromBottom //change to whatever animation you like animations:^ { [self.view addSubview:myImageView1]; [self.view addSubview:myImageView2]; } completion:^ { NSLog(@"Animations completed."); // do something... }];
解决方法
你只是有错误的块类型:)它需要一个像下面这样的块.关键是^(BOOL完成){…}
[UIView transitionWithView:self.view duration:1.5 options:UIViewAnimationOptionTransitionFlipFromBottom //change to whatever animation you like animations:^ { [self.view addSubview:myImageView1]; [self.view addSubview:myImageView2]; } completion:^(BOOL finished){ if (finished) { // Successful } NSLog(@"Animations completed."); // do something... }];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。