Ios 如何创建转换navigationcontroller?
我想要两个Ios 如何创建转换navigationcontroller?,ios,objective-c,transform,Ios,Objective C,Transform,我想要两个UIViewControllers之间的转换,就像推送转换一样。 使用“推送变换”默认值时,视图从右向左变换。但我希望我的观点从左到右转变 请给我指点一下这可能会有帮助。虽然我相信一定有更好的办法 UIViewController *vc = [[UIViewController alloc] init]; // create the new view controller to "push" NSArray *viewControllers = self.naviga
UIViewControllers
之间的转换,就像推送转换一样。
使用“推送变换”默认值时,视图从右向左变换。但我希望我的观点从左到右转变
请给我指点一下这可能会有帮助。虽然我相信一定有更好的办法
UIViewController *vc = [[UIViewController alloc] init]; // create the new view controller to "push"
NSArray *viewControllers = self.navigationController.viewControllers;
NSMutableArray *mutableViewControllers = [viewControllers mutableCopy];
NSInteger indexOfSelf = [mutableViewControllers indexOfObject:self];
[mutableViewControllers insertObject:vc atIndex:indexOfSelf];
[self.navigationController setViewControllers:mutableViewControllers];
[self.navigationController popViewControllerAnimated:YES]; // actually, it's a "pop" action
我拿了这个解决方案,对它进行了修改,使它看起来稍微干净一点,并从想要的方向推动。虽然它具有所需的方向动画,但导航栏中有一些我无法消除的闪烁
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:yourViewControllerHere animated:NO];
还要记住,用户非常习惯于从右侧推入下一个视图控制器。在更改标准项的外观/感觉之前,请仔细考虑,因为这样可能会混淆用户。您能给出代码示例吗?如果这样做,您将不会有后退按钮。我的朋友,如何更改后退按钮的转换?我不明白这个问题。你是说当按下“后退”按钮时,你还想更改转换方向吗?我的朋友,我说当转到下一页时,我的视图从左到右转换,当单击“后退”按钮时,从右到左转换如果你想覆盖“后退”按钮的默认行为,您需要创建自己的
UIBarButtonItem
,并将其设置为左侧导航项。它将看起来与默认的后退按钮略有不同,并失去一些附带的额外功能。您只需要反转上面代码中的方向并手动管理导航堆栈。