iphone - [self.navigationController popViewControllerAnimated :YES];? 之后调用什么方法

标签 iphone methods viewwillappear

我有这个代码:

-(IBAction)OkButtonPressed:(id)sender{
    NSLog(@"BTN OK");
    RecherchePartenaireTableView *recherchePartenaireTableView=[[RecherchePartenaireTableView alloc]init];
    recherchePartenaireTableView.mytext=textFieldCode.text;

    [self.navigationController popViewControllerAnimated:YES];
}

按“确定”后,我在控制台中看到消息“BTN OK”,没有其他内容。在 RecherchePartenaireTableView 类中,我有方法 viewWillAppear、viewDidload... 以及每个方法的 NSLog 消息。 [self.navigationController popViewControllerAnimated:YES]; 之后调用了什么方法?

最佳答案

如果您尝试设置类 RecherchePartenaireTableView 的属性,该类已经位于导航堆栈上,那么您创建它的新实例就错了。

您应该从 navigationController 堆栈中取回该实例。

改变

RecherchePartenaireTableView *recherchePartenaireTableView=[[RecherchePartenaireTableView alloc]init];
recherchePartenaireTableView.mytext=textFieldCode.text;

NSArray *viewControllers = [self.navigationController viewControllers];
RecherchePartenaireTableView *recherchePartenaireTableViewVC = (RecherchePartenaireTableView *)[viewControllers objectAtIndex:viewControllers.count - 2];
recherchePartenaireTableViewVC.mytext=textFieldCode.text;

viewDidAppear 方法将在您推送 View 的类上调用。

关于iphone - [self.navigationController popViewControllerAnimated :YES];? 之后调用什么方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7498687/

相关文章:

iphone - 如何在 subview 中处理 UITapGestureRecognizer?

iphone - 当我在没有动画的情况下插入多个 Controller 时,布局出现问题

ios - 在触发预定的 UILocalNotification 之前调用的方法?

java - 如何将方法从A类传递到B类

java - 从 ArrayList 内部方法获取数据

Android SDK 等同于 viewWillAppear (iOS)?

iphone - 在 UICollectionView 中更改菜单的标签标题

java - 在一个方法调用仍在进行时调用第二个方法会导致程序崩溃

swift - ViewWillAppear 在 UITableViewCell 上?

ios - viewWillAppear 触摸屏后调用