Ios 故事板序列过渡效果
第一次海报,长期观察者 我正在为我目前正在开发的一个应用程序使用故事板,并且需要更多的过渡,而不仅仅是向前,尤其是向后。每当我使用此序列返回菜单时,单击下一步按钮转到另一个ViewController,将使整个应用程序崩溃 不知道发生了什么,我在实现文件中使用了这个Ios 故事板序列过渡效果,ios,xcode,uistoryboard,uistoryboardsegue,Ios,Xcode,Uistoryboard,Uistoryboardsegue,第一次海报,长期观察者 我正在为我目前正在开发的一个应用程序使用故事板,并且需要更多的过渡,而不仅仅是向前,尤其是向后。每当我使用此序列返回菜单时,单击下一步按钮转到另一个ViewController,将使整个应用程序崩溃 不知道发生了什么,我在实现文件中使用了这个 #import "SlideLeftSegue.h" @implementation SlideLeftSegue - (void)perform{ UIView *sv = ((UIViewController *)s
#import "SlideLeftSegue.h"
@implementation SlideLeftSegue
- (void)perform{
UIView *sv = ((UIViewController *)self.sourceViewController).view;
UIView *dv = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
dv.center = CGPointMake(sv.center.x - sv.frame.size.width, dv.center.y);
[window insertSubview:dv belowSubview:sv];
[UIView animateWithDuration:0.4
animations:^{
dv.center = CGPointMake(sv.center.x,
dv.center.y);
sv.center = CGPointMake(sv.center.x + sv.frame.size.width,
dv.center.y);
}
completion:^(BOOL finished){
[[self destinationViewController]
dismissViewControllerAnimated:NO completion:nil];
}];
}
@end
这是我的头文件
#import <UIKit/UIKit.h>
// Move to the previous screen with slide animation.
@interface SlideLeftSegue : UIStoryboardSegue
@end
#导入
//使用幻灯片动画移动到上一屏幕。
@界面SlideLeftSegue:UIStoryboardSegue
@结束
我还在学习,所以如果你知道发生了什么,我非常感谢初学者的解释。你可以用更少的代码实现这一点 要显示视图控制器,请执行以下操作:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"ViewID"];
view.modalTransitionStyle = UIModalTransitionStyleCoverVertical; // you can try the other 3 UIModalTransitionStyle too
[self presentViewController:view animated:YES completion:nil];
返回:
[self dismissViewControllerAnimated:YES completion:nil];
您可以用更少的代码实现这一点 要显示视图控制器,请执行以下操作:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"ViewID"];
view.modalTransitionStyle = UIModalTransitionStyleCoverVertical; // you can try the other 3 UIModalTransitionStyle too
[self presentViewController:view animated:YES completion:nil];
返回:
[self dismissViewControllerAnimated:YES completion:nil];
我那样做了,这就是它对我的回击。“SlideLeftSegue”没有可见的@interface声明选择器“dismissViewControllerAnimated:completion:”仅供参考,当它试图使用SlideLeftSegue在屏幕之间移动时崩溃,它会说“Thread 1:EXC_BAD_ACCESS(code=EXC_I386_GPFLT)”,我理解的是,您试图通过按下某种按钮来表示视图。在故事板中,为什么不在源代码视图控制器中设置一个按钮,然后使用命令“拖动”将按钮连接到目标视图。在那之后,回到你的VC源代码,使用上面的代码。是的,假设我有VC1和VC2。在VC1上,我有一个按钮,我命令它拖到VC2上,然后按下该按钮。在VC2上,我有一个按钮,我命令将其拖动到VC1,并将segue设置为自定义的SlideLeftSegue。我不确定我做错了什么,因为这个左segue对我不起作用。好的,试试这个:取消第二个segue,并将segue 1中的“推送”改为“模式”。我马上发送一个示例项目。我做到了,这就是它对我的回击。“SlideLeftSegue”没有可见的@interface声明选择器“dismissViewControllerAnimated:completion:”仅供参考,当它试图使用SlideLeftSegue在屏幕之间移动时崩溃,它会说“Thread 1:EXC_BAD_ACCESS(code=EXC_I386_GPFLT)”,我理解的是,您试图通过按下某种按钮来表示视图。在故事板中,为什么不在源代码视图控制器中设置一个按钮,然后使用命令“拖动”将按钮连接到目标视图。在那之后,回到你的VC源代码,使用上面的代码。是的,假设我有VC1和VC2。在VC1上,我有一个按钮,我命令它拖到VC2上,然后按下该按钮。在VC2上,我有一个按钮,我命令将其拖动到VC1,并将segue设置为自定义的SlideLeftSegue。我不确定我做错了什么,因为这个左segue对我不起作用。好的,试试这个:取消第二个segue,并将segue 1中的“推送”改为“模式”。我马上发送一个示例项目。