- 两个控制器,
viewcontroller
---push---secondviewcontroller
。。。viewcontroler
中有一个button
(用来push到第二个控制器,还有一个lable
(用来展示第二个页面blcok
传过来的值 - 下面贴过来两个控制器中详细代码
viewcontroller.h
typedef NSString *(^mssblock)(NSString *);
@interface ViewController : UIViewController
@property (nonatomic ,copy) mssblock mss;
@property (weak, nonatomic) IBOutlet UILabel *showtexlable;
@end
viewcontroller.m
#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)pushpressed:(id)sender {
SecondViewController *vc =[SecondViewController new];
[self.navigationController pushViewController:vc animated:YES];
[vc returnmessage:^(NSString *str) {
self.showtexlable.text =str;
}];
}
@end
secondviewcontroller.h
#import <UIKit/UIKit.h>
typedef void(^mssblcokdemo)(NSString *str);
@interface SecondViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *textfild;
@property (nonatomic ,strong) mssblcokdemo block;
-(void)returnmessage:(mssblcokdemo)block;
@end
secondviewcontroller.m
#import "SecondViewController.h"
@interface SecondViewController ()<UITextFieldDelegate>
@end
@implementation SecondViewController
- (IBAction)backpressed:(id)sender {
self.block(_textfild.text);
[self.navigationController popViewControllerAnimated:YES];
}
-(void)returnmessage:(mssblcokdemo)block{
self.block=block;
}
@end
(由于系统键盘问题,键盘转换大小写卡顿很严重,mini盒子就这样,不适合开发,自己穷不怪公司,你们得谅解呀,不懂得地方可以留言,或者加qq 517769958)