@interface CustomViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@end
@implementation CustomViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor cyanColor];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//可视化编程页面跳转方式(storyBoard)
[self performSegueWithIdentifier:@"custom" sender:nil];
}
//这个是只要有segue那根线,也就是页面之间的跳转就会执行这个方法。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//获取目的控制器
ViewController *vc = (ViewController *)segue.destinationViewController;
//获取源控制器
// CustomViewController *cvc = (ViewController *)segue.sourceViewController;
if ([segue.identifier isEqualToString:@"push"]) {
//传值
vc.text = self.textField.text;
}else
{
NSLog(@"其他情况");
}
}
============================
#import "CustomSegue.h"
@implementation CustomSegue
//自定义segue会自动触发此方法.
-(void)perform{
//第一步:获取源控制器
UIViewController *v1 = (UIViewController *)self.sourceViewController;
//第二步:获取目标控制器
UIViewController *v2 = (UIViewController *)self.destinationViewController;
//第三步:自定义页面切换效果
[UIView transitionFromView:v1.view toView:v2.view duration:2 options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished){
}];
}
@end