使用CATransition从右向左和向后过渡?

ste*_*osn 2 iphone objective-c ios

我有一个uitabbarcontroller,由五个uiview控制器组成.

当我点击第一个uiviewcontroller视图中的按钮时,我想要隐藏uiviewcontroller,并添加一个从右到左过渡的新uiviewcontroller.我已经实现了这一点但是当我点击新视图上的按钮时,应用程序崩溃!按钮没有附加代码.我收到EXEC_BAD_ACCESS错误.

有谁知道为什么会发生这种情况以及如何用新视图克服这个问题?

当我尝试模态视图转换时,视图正常运行.当我尝试使用CATransition时会发生这种情况.我需要CATransition,因为modalview过渡没有从右到左或从左到右的过渡!

任何帮助赞赏!

ste*_*osn 5

这是在tabviewcontroller的Uiview和新的uiview之间进行转换所需的代码.代码转到按钮的IBAction,它存在于tabviewcontroller的一个uiviews中.

//初始化app委托

AppDelegate appDelegate =(AppDelegate)[[UIApplication sharedApplication] delegate];

//获取当前显示的视图

UIView*currentView = self.view;

//获取底层UIWindow或包含当前视图视图的视图

UIView*theWindow = [currentView superview];

// remove the current view and replace with mynewView1
[currentView removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)

//将新视图分配给viewcontroller1.它是uitabbarcontroller的第一个uiviewcontroller.我的uitabbarcontroller在我的项目中包含五个uiviewcontrollers.该按钮存在于第一个viewcontroller1中,这就是我将新视图分配给viewcontroller1的原因.如果从我的uitabbarcontroller的secondviewcontroller(viewcontroller2)按下按钮,我会将新视图分配给secondviewcontroller(viewcontroller2),依此类推......

appDelegate.viewController1=[[MyMessages alloc] initWithNibName:@"MyMessages" bundle:nil];
Run Code Online (Sandbox Code Playgroud)

//将其添加到窗口中

[theWindow addSubview:appDelegate.viewController1.view];

// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!我已经尝试了一天以上来实现它.我希望它能帮助有同样问题的人.