Xcode 无法识别 UIViewAnimationOptionTransitionFlipFromRight
我正在实现一个非常简单的翻转动画,但翻转不存在。
我使用文档中的示例作为模板,Apple 现在建议您使用动画块,这是要采取的方法:(来自文档)
[UIView transitionWithView:containerView
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
completion:NULL];
将要在容器中转换的两个视图包装起来。 我就是这样做的。
UIView *container = [[UIView alloc] initWithFrame:target];
[self.view addSubview:container];
[container addSubview:productImage];
UIView *background = [[UIView alloc] initWithFrame:target];
[background setBackgroundColor:[UIColor darkGrayColor]];
[background setAlpha:0.1f];
[UIView transitionWithView:container
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[[[container subviews] objectAtIndex:0] removeFromSuperview];
[container addSubview:background];
}
completion:NULL];
发生了两件奇怪的事情: 没有过渡,容器显示productImage(类型为UIImageView),然后将其与背景视图交换。没有动画。
第二件事让我相信这不是常见的拼写错误,而是
UIViewAnimationOptionTransitionFlipFromRight
Xcode 无法识别,它不会自动完成,也不会突出显示。仅当我使用已弃用的版本时,Xcode 才会执行此操作:
UIViewAnimationTransitionFlipFromRight //i.e. without the Option part
然后我开始检查我的 SDK 版本等。所有内容似乎都设置为 4.2,XCode 版本为 3.2.5,目标和项目设置都将构建和部署目标设置为 4.2。
我在这里缺少什么?
希望训练有素的眼睛可以帮助我:) 提前谢谢你。
I am implementing a very simple flip animation, but the flip isn't there.
I am using an example from the docs as a template, Apple now recommends you use blocks for animations and that this is the approach to take: (from the docs)
[UIView transitionWithView:containerView
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
completion:NULL];
Wrapping the two views you want to transition between in a container.
I do it like this.
UIView *container = [[UIView alloc] initWithFrame:target];
[self.view addSubview:container];
[container addSubview:productImage];
UIView *background = [[UIView alloc] initWithFrame:target];
[background setBackgroundColor:[UIColor darkGrayColor]];
[background setAlpha:0.1f];
[UIView transitionWithView:container
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[[[container subviews] objectAtIndex:0] removeFromSuperview];
[container addSubview:background];
}
completion:NULL];
Two strange things happen:
There is no transition, the container displays the productImage (of type UIImageView), then swaps it with the background view. No animation.
The second thing is what led me to believe that this is not the usual typo, was that the
UIViewAnimationOptionTransitionFlipFromRight
is not recognized by Xcode, it will not autocomplete, it is not highlighted. Xcode will only do that if I use the deprecated:
UIViewAnimationTransitionFlipFromRight //i.e. without the Option part
I then started to check my SDK version etc. everything seems to be set to 4.2, XCode is version 3.2.5, both target and project settings has build and deploy target set to 4.2.
What am I missing here?
Hope a set of trained eyes can help me:) thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您要使用块(每个人都应该开始使用它们),请参阅
+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView 持续时间:(NSTimeInterval)持续时间选项:(UIViewAnimationOptions)选项完成:(void (^)( BOOL完成))完成
和/或
+ (void)transitionWithView:(UIView *)视图持续时间:(NSTimeInterval)持续时间选项:(UIViewAnimationOptions)选项动画: (void (^)(void))动画完成:(void (^)(BOOL finish))完成
If you are going with blocks (and everyone should start going with them), please refer to
+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion
and/or
+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
这段代码可以帮助你
干杯
This code will help you
Cheers