bug:viewcontroller添加UITableView使用scrollviewdidscroll popviewcontrolleranimated崩溃

遇到了这个问题,然后查找了 Stackoverflow 下面是问题,然后还有Stackoverflow上面的回答:Stackoverflow

Here is all my code :

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pushTableViewController:)];
    self.navigationItem.leftBarButtonItem = leftItem;

}
- (void)pushTableViewController:(id)sender {
    TableViewController *tableViewController = [[TableViewController alloc]init];
    [self.navigationController pushViewController:tableViewController animated:YES];

}

The TableViewController code is:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIBarButtonItem *myMessageButton = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(myMessageButtonClicked:)];
    self.navigationItem.leftBarButtonItem = myMessageButton;
    UITableView *scrollTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    scrollTableView.delegate = self;
    scrollTableView.dataSource = self;
    [self.view addSubview:scrollTableView];
}
- (void)myMessageButtonClicked:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

}

Just use the most simplest way to use UITableView
,and implement scrollViewDidScroll
when I scroll the UITableView
to the bottom and then popViewControllerAnimated
i got crash. is this BUG of IOS? or where did i go wrong?

比较认同的答案:

The problem is,tableview try to access scrollViewDidScroll
delegate method during the time of animating viewController. so after reaching scroll at bottom, set datasource anddelegateas Nil before popViewController.

你可能感兴趣的:(bug:viewcontroller添加UITableView使用scrollviewdidscroll popviewcontrolleranimated崩溃)