Forward delivery
When a controller switches to the next control, this time the data is passed forward, so only need to jump before the execution of a method on the line.
/*就是执行控制器跳转之间的那条线之前做的方法*/- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // 1.取得目标控制器 UIViewController *contactVc = segue.destinationViewController; // 2.设置标题 contactVc.title = [NSString stringWithFormat:@"%@的联系人列表"self.accountField.text];}
Reverse Delivery
When a controller needs to switch to his last controller, it needs to use proxy mode when passing data to the previous controller.
Suppose control B is going to transfer the data to the previous controller A
A proxy agreement is declared in B
@protocol MJEditViewControllerDelegate <NSObject>@optional//A要执行的方法,B会把数据传递给设个方法,A实现这个方法设置自己的数据,@end
A adhere to this protocol, then implement the method in the protocol, then set its agent to a in B
b Get the data ready, then notify his agent A.
//2. Notification Agent if([ Self. DelegateRespondstoselector:@selector(Proxy method:)]) {//Update model data Self. Contact. Name= Self. NameField. Text; Self. Contact. Phone= Self. Phonefield. Text; [ Self. DelegateEditviewcontroller: SelfDidsavecontact: Self. Contact]; }
"iOS Development-data transfer" About two controller jump data transfer