直接创建两个控制器,点击跳转第二个界面,然后点击按钮进行传值

#import "ViewController.h"

#import "TWOOViewController.h"

@interface ViewController ()

@property(nonatomic,weak)UILabel * label;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

UIButton * nextBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width, 50)];

nextBtn.backgroundColor = [UIColor redColor];

[nextBtn addTarget:self action:@selector(nextBtnClick:) forControlEvents:UIControlEventTouchUpInside];

[nextBtn setTitle:@"下一个界面" forState:UIControlStateNormal];

[self.view addSubview:nextBtn];

UILabel * labeltext = [[UILabel  alloc]initWithFrame:CGRectMake(0, 150, self.view.bounds.size.width, 50)];

labeltext.backgroundColor = [UIColor yellowColor];

labeltext.textColor = [UIColor greenColor];

[self.view addSubview:labeltext];

self.label = labeltext;

//创建通知

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(nexttow:) name:@"nextBtnaa" object:nil];

}

-(void)nextBtnClick:(UIButton*)nextBtn{

TWOOViewController * two = [[TWOOViewController alloc]init];

[self presentViewController:two animated:YES completion:nil];

}

-(void)nexttow:(NSNotification*)nontification{

self.label.text = nontification.object;

}

第二个控制器

#import "TWOOViewController.h"

@interface TWOOViewController ()

@end

@implementation TWOOViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.view.backgroundColor = [UIColor blueColor];

UIButton  * backBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 79, self.view.bounds.size.width, 50)];

[backBtn setTitle:@"回" forState:UIControlStateNormal];

[backBtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:backBtn];

}

-(void)backBtnClick:(UIButton*)backBtn{

[[NSNotificationCenter defaultCenter]postNotificationName:@"nextBtnaa" object:@"逆传值"];

//隐藏本控制器

[self dismissViewControllerAnimated:YES completion:nil];

}

结果:

最新文章

  1. 一个简单的MVC实例及故障排除
  2. [非原创]eclipse中一些常见svn图标的含义
  3. [C#基础知识] ReadOnly关键字修饰的变量可以修改,只是不能重新分配
  4. EF架构~数据分批批量提交
  5. Elasticsearch聚合初探——metric篇
  6. TCP/IP 协议介绍
  7. 关于Hibernate中的Configuration
  8. 关于java对象的思考
  9. Gridview中修改某列的背景色
  10. CentOS6.7 下安装git
  11. iOS PureLayout使用
  12. Qt之添加图标
  13. Google Maps API的使用
  14. BZOJ 2594 水管局长数据加强版
  15. 【NET Core】Nuget包发布流程
  16. linux中gdb的使用
  17. Elastic Stack之ElasticSearch分布式集群二进制方式部署
  18. 使用Nexus配置Maven私有仓库
  19. (转)深度学习目标检测指标mAP
  20. CCF CSP认证考试试题

热门文章

  1. shell面试题目总结
  2. Web 服务器 low bandth DOS attack
  3. 一个DNS统计,RCFs,工具站点
  4. mongodb学习(一)
  5. 系统右键菜单添加剪贴板清空项(隐藏DOS窗口)
  6. Redis与Memcache的区别
  7. vi编辑器的使用
  8. Windows服务安装与卸载
  9. WCF简单使用(分别部署在控制台和IIS上)
  10. 几个js函数