//可视化编程,传值用到的调用方法,一些传值的操作必须写在这里
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"abc"]) {
FirstViewController *first = segue.destinationViewController;
first.string = @"琪琪";
}
}
6EAFE986-4B68-4B00-BB3C-8000AE5797CE.png
- (void)perform{
//获取源控制器
ViewController *sourceVc = self.sourceViewController;
//获取目标控制器
FirstViewController *firstVC = self.destinationViewController;
//添加动画
[UIView transitionFromView:sourceVc.view toView:firstVC.view duration:2 options:(UIViewAnimationOptionTransitionFlipFromTop) completion:^(BOOL finished) {
//动画完成的操作,
// 动画只是实现视图的切换,还需要使用push或者model将控制器切换过来
sourceVc.navigationController showViewController:firstVC sender:nil];
}];
-
自定义的视图
当想在前一页通过触摸方法,跳转到自定义的可视化视图时,可以通过下边的代码实现,前提也是对自定义的可视化视图进行标识符的书写,此处我命名的标识符为model
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//1. 先从当前包里找到故事板
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
//2. 通过标识符在故事板面找到对应的目标控制器
ModalViewController *modal = [sb instantiateViewControllerWithIdentifier:@"modal"];
//[self presentViewController:modal animated:YES completion:nil];
//[self showDetailViewController:modal sender:nil];
[self showViewController:modal sender:nil];
}