SecondViewController.m
#import "SecondViewController.h"
@interface SecondViewController ()
/** 用于写入数据,最后将数据返回给第一个界面 */
@property (weak, nonatomic) IBOutlet UITextField *second2First;
/** 用于显示第一个界面传过来的数据 */
@property (weak, nonatomic) IBOutlet UITextField *displayWithFirst;
/** 点击此按钮,第二个控制器将弹出栈,界面将返回到第一个界面 */
- (IBAction)second2First:(UIButton *)sender;
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
//显示第一个界面传递过来的数据信息
self.displayWithFirst.text = self.name;
}
//点击该按钮,数据将返回给第一个界面显示
- (IBAction)second2First:(UIButton *)sender {
if (self.second2First.text.length > 0) {
//如果有实现该协议方法的控制器,则将数据传给该控制器
if ([self.delegate respondsToSelector:@selector(secondViewControllerDidDit:andName:)]) {
[self.delegate secondViewControllerDidDit:self andName:self.second2First.text];
}
}
[self.navigationController popViewControllerAnimated:YES];
}
@end
以上就是本文的全部内容,希望能给大家一个参考,也希望大家多多支持ASPKU。
注:相关教程知识阅读请移步到IOS开发频道。










