iOS pop回父级页面,使用通知传值
输入所要发送的信息 ,同时将label的值通过button方法调用传递,

- (IBAction)buttonClick:(id)sender {

    //添加 字典,将label的值通过key值设置传递

    NSDictionary *dict =[[NSDictionary alloc]initWithObjectsAndKeys:self.textFieldOne.text,@"textOne",self.textFieldTwo.text,@"textTwo", nil];

    //创建通知

    NSNotification *notification =[NSNotification notificationWithName:@"tongzhi" object:niluserInfo:dict];

    //通过通知中心发送通知

    [[NSNotificationCenter defaultCenter] postNotification:notification];

    [self.navigationController popViewControllerAnimated:YES];

 

}

在发送通知后,在所要接收的控制器中注册通知监听者,将通知发送的信息接收

- (void)viewDidLoad {

    [super viewDidLoad];

    //注册通知

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

 

}

- (void)tongzhi:(NSNotification *)text{

    NSLog(@"%@",text.userInfo[@"textOne"]);

        NSLog(@"-----接收到通知------");

 

}

相关文章:

  • 2021-12-22
  • 2022-12-23
  • 2021-09-27
  • 2021-09-01
  • 2021-12-27
  • 2022-12-23
  • 2021-12-02
  • 2021-06-29
猜你喜欢
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案