iPhone视图翻转:视图从上到下翻转,而不是从右到左
我尝试构建一个始终处于横向模式的应用程序。 我做了平常的事情: plist 添加了 UIInterfaceOrientation / UIInterfaceOrientationLandscapeRight 在界面生成器中旋转 XIB,并使用视图顶部的小箭头。
my code for launching:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
FlipViewController *flip = [[FlipViewController alloc] initWithNibName:@"FlipViewController" bundle:nil];
[window addSubview:flip.view];
[window makeKeyAndVisible];
}
但是当我尝试执行“UIViewAnimationTransitionFlipFromLeft”时,页面从上到下翻转,而不是从右到左翻转。 :-/
这是我用来翻转视图的代码:
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
UIViewController *coming = nil;
UIViewController *going = nil;
UIViewAnimationTransition transition;
if (self.blueViewController.view.superview == nil)
{
coming = blueViewController;
going = yellowViewController;
transition = UIViewAnimationTransitionFlipFromLeft;
}
else
{
coming = yellowViewController;
going = blueViewController;
transition = UIViewAnimationTransitionFlipFromRight;
}
[UIView setAnimationTransition: transition forView:self.view cache:YES];
[coming viewWillAppear:YES];
[going viewWillDisappear:YES];
[going.view removeFromSuperview];
[self.view insertSubview: coming.view atIndex:0];
[going viewDidDisappear:YES];
[coming viewDidAppear:YES];
[UIView commitAnimations];
“窗口”似乎忽略了一个事实,即它处于横向模式。嗯。 谁能发现我的错误吗?
i try to build a app that is in landsscape mode all the time.
I did the usual stuff:
plist added UIInterfaceOrientation / UIInterfaceOrientationLandscapeRight
rotated the XIBs in interface builder with the little arrow in top of view.
my code for launching:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
FlipViewController *flip = [[FlipViewController alloc] initWithNibName:@"FlipViewController" bundle:nil];
[window addSubview:flip.view];
[window makeKeyAndVisible];
}
But when i try to do a "UIViewAnimationTransitionFlipFromLeft" the page flips from top to bottom instead of right to left. :-/
This is the code i use to flip the views:
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
UIViewController *coming = nil;
UIViewController *going = nil;
UIViewAnimationTransition transition;
if (self.blueViewController.view.superview == nil)
{
coming = blueViewController;
going = yellowViewController;
transition = UIViewAnimationTransitionFlipFromLeft;
}
else
{
coming = yellowViewController;
going = blueViewController;
transition = UIViewAnimationTransitionFlipFromRight;
}
[UIView setAnimationTransition: transition forView:self.view cache:YES];
[coming viewWillAppear:YES];
[going viewWillDisappear:YES];
[going.view removeFromSuperview];
[self.view insertSubview: coming.view atIndex:0];
[going viewDidDisappear:YES];
[coming viewDidAppear:YES];
[UIView commitAnimations];
"window" seems to have missed the fact, that it is in landsscape-mode. Hmmm.
can anyone spot my mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用记录的方法是不可能的。
您需要使用CATransition。 (CATransition 本身已记录,但翻转过渡没有记录。)
要使用翻转过渡,请将过渡的
type
设置为“oglFlip”并设置subtype 到 fromLeft/Top/Right/Bottom。
Not possible with documented methods.
You need to use CATransition. (CATransition itself is documented, but the flip transition is not.)
To use the flip transition, set the transition's
type
to "oglFlip" and setsubtype
to fromLeft/Top/Right/Bottom.