如何返回上一个界面并传值给上一个界面

- (void) goBackToPersonInfoVCWithNickName:(NSString *) nickName{
    //            [self.navigationController popViewControllerAnimated:YES];
    //此页面已经存在于self.navigationController.viewControllers中,并且是当前页面的前一页面
    PersonInfoViewController *personVC = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count-2];
    //初始化其属性
    //            personVC.sexInt = _sex;
    //传递参数过去
    personVC.nickName = nickName;
    //使用popToViewController返回并传值到上一页面
    [self.navigationController popToViewController:personVC animated:true];
    
}

你可能感兴趣的:(iOS,iOS研发进阶之路)