SecondViewController.h
#warning第一步:声明协议方法
@protocolpassValueDelegate
-(void)passContent:(NSString*)content;
@end
SecondViewController.h
#warning第二步:声明代理人属性
@property(nonatomic,assign)iddelegate;
SecondViewController.m
-(void)didClickedButton:(UIButton*)button{
#warning第三步:命令代理人执行协议方法
[self.delegatepassContent:self.textField.text];
[self.navigationControllerpopToRootViewControllerAnimated:YES];
}
RootViewController.m
#warning第四步:前一页签协议
@interfaceRootViewController()
RootViewController.m
-(void)didClickedButton:(UIButton*)button{
SecondViewController* secVC = [[SecondViewControlleralloc]init];
secVC.passString=self.label.text;
#warning第五步:设置代理人
secVC.delegate=self;
[self.navigationControllerpushViewController:secVCanimated:YES];
}
RootViewController.m
#warning第六步:实现协议方法
-(void)passContent:(NSString*)content{
self.label.text= content;
}