博客> 页面跳转viewDidLoad方法不走
页面跳转viewDidLoad方法不走
2017-10-17 12:23 评论:0 阅读:225 1498893132
ios 界面跳转
  如果你在使用push 方法进行A界面跳转到B界面,第一次的时候- (void)viewDidLoad方法有走,而之后,再次进行从B界面返回到A界面,再次从A界面跳转到B界面,此时会发现- (void)viewDidLoad方法不走,原因:

此时查看,是否将B类写成了全局变量 例如 @property(nonatomic,strong)RefundViewController *refundVc;

-(RefundViewController *)refundVc { if (!_refundVc) { _refundVc=[[RefundViewController alloc]init]; } return _refundVc; }

跳转的地方 refundVC.statu = _statu; refundVC.ordergoodid = _good_ordergoodsid; refundVC.refundprice = [_refundprice floatValue]; refundVC.ordernumber = self.ordernumber; refundVC.recordisreceive = self.isreceive; refundVC.recordrefundtype = self.isreceiverefundtype; [self.navigationController pushViewController:self.refundVc animated:YES]; 这样的写法是 使得B类- (void)viewDidLoad 不走的原因

修改成 RefundViewController *refundVC = [[RefundViewController alloc] init]; refundVC.statu = _statu; refundVC.ordergoodid = _good_ordergoodsid; refundVC.refundprice = [_refundprice floatValue]; refundVC.ordernumber = self.ordernumber; refundVC.recordisreceive = self.isreceive; refundVC.recordrefundtype = self.isreceiverefundtype; [self.navigationController pushViewController:refundVC animated:YES]; 即可

收藏
0
sina weixin mail 回到顶部