Iphone 视图控制器转换

Iphone 视图控制器转换,iphone,objective-c,ios,transition,Iphone,Objective C,Ios,Transition,我有密码: ListViewController * listViewController = [[ListViewController alloc] initWithNibName:@"ListViewController" bundle:nil]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.5]; [UIView setAnimationCurve:UIViewAnimation

我有密码:

ListViewController * listViewController = [[ListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];    

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[self viewWillDisappear:YES];
[listViewController viewWillAppear:YES];

self.view.hidden = YES;
listViewController.view.hidden = NO;


[self viewDidDisappear:YES];
[listViewController viewDidAppear:YES];
[UIView commitAnimations];    

但是它不工作,listViewController也不显示(请,有人能告诉我这个问题的解决方案吗?

删除不必要的代码,然后写下这个

ListViewController * listViewController = [[ListViewController alloc] initWithNibName:@"ListViewController" bundle:nil];    
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[self.view addSubview:listViewController.view];
[UIView commitAnimations];
尝试以下方法:

UIViewAnimationOptions ops = UIViewAnimationOptionTransitionFlipFromRight;
NSArray *temp = [[NSBundle mainBundle] loadNibNamed:@"NameOfNib" owner:self options:nil];
UIView* newView = [[temp objectAtIndex:0] view];
[UIView transitionFromView:self.view toView:newView duration:1.5 options:ops completion:nil];
self.view = newView; //Lets you control the new view from the current controller (you might want to save a reference to the old one if you need to change back)
正如meronix所说,苹果不鼓励在较新的iOS版本中使用非块动画。上述方法是“认可”的方法

正如您所知,
视图将出现
视图将消失
,类似的方法不是您调用以使视图执行操作的方法。当这些操作发生时,它们会自动调用

您的代码有一些误解;我在下面对它们进行了评论

//This looks fine (depending on what is in the nib)
ListViewController * listViewController = [[ListViewController alloc] initWithNibName:@"ListViewController" bundle:nil]; 

//Normally I use these to move things around, not change the view
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

[self viewWillDisappear:YES]; //These two methods aren't things that you call
[listViewController viewWillAppear:YES];

self.view.hidden = YES; //If you're flipping or otherwise moving a view out of 
listViewController.view.hidden = NO; //sight then you don't need to hide/unhide views

[self viewDidDisappear:YES]; //Same as above, you don't call these
[listViewController viewDidAppear:YES];
[UIView commitAnimations]; 
它不能工作

您只需创建并分配UIViewController,但决不将其推送到任何堆栈上,或将其视图添加到可见视图中

当您将listViewController.view.hidden设置为“否”时,您并没有神奇地在屏幕上显示它:您需要将其视图添加到已在屏幕上的视图(或窗口)中


ps beginAnimation已被弃用:改用块动画…

当我使用此代码时,我的当前视图(它是地图视图)仅在现场旋转..((我需要更改我的当前视图(IBMMapView*map)到listView.it将翻转listViewController.view您可以翻转任何视图只需将listViewController.view替换为您的视图。因为在您的问题中,您只是要求翻转。
beginAnimations
并没有遭到反对……我认为这只是不被鼓励。不,您是,对的,苹果只是说:“在iOS 4.0及更高版本中不鼓励使用此方法。您应该使用基于块的动画方法来指定动画。”和:“在iOS 4及更高版本中,使用基于块的动画方法。(推荐)“好吧,我很担心,不得不检查一下,因为我的一些老应用程序使用了
beginAnimations
,我不想被iOS 6搞砸。此外,你会看到我的回答确实建议采用基于块的方法:-——正如我所说的,你是对的,推荐只是意味着苹果迟早会将其签为折旧,也许在遥远的将来(让我们希望)…无论如何,我喜欢beginAnimation方法,但只是‘因为我习惯了它们……然后我强迫自己使用block,现在我喜欢它们……我只是一个初学者,想和一个有经验的开发人员谈谈。)谢谢你的澄清!!)我仍在处理这个问题)我是objective-c新手((如果您需要一些教程,请查看。几乎所有人都极力推荐这些教程。