demo设计,A页面有一个标签和一个按钮,点击按钮进入C页面,C页面有一个按钮和一个输入框,在输入框输入内容,点击按钮可以返回A页面,A页面的标签上显示C页面输入的内容。

A页面的代码:

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *showLabel;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
}
- (IBAction)popToBView:(UIButton *)sender {    
    CViewController *bview = [[CViewController alloc] initWithNibName:@"CViewController" bundle:nil];
    if (!bview.myblock) {
        bview.myblock = ^(NSString *TextStr){
            self.showLabel.text = TextStr;
        };
    }
    [self.navigationController pushViewController:bview animated:YES];
}

C页面的代码:

.h文件:

@interface CViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *inputText;
@property(nonatomic,copy) void (^myblock)(NSString *myText);
@end

.m文件:

- (IBAction)backToA:(id)sender {    
    NSString *str = self.inputText.text;
    self.myblock(str);
    [self.navigationController popToRootViewControllerAnimated:YES];
}