我要实现的效果:在ViewController里有一个Button,点击button进入BlockView。在BlockView有一个TextField,输入文字后点击完成,可以把textField里的文字回调到ViewController的Button上显示。
第一种:delegate回调
回调类ViewController.m:#import "ViewController.h"
#import "BlockView.h"
@interface ViewController ()<BlockViewDelegate>
@property (strong, nonatomic) UIButton *myButton;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor whiteColor];
self.myButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 60, 30)];
self.myButton.backgroundColor = [UIColor redColor];
[self.myButton addTarget:self action:@selector(doButtonAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.