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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,449评论 0 23
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 14,595评论 5 6
  • 春天来了,即使在帝都这个靠北的城市,也处处洋溢着春天的气息。窗外的小鸟欢快地叫着,透过朋友圈我能感受到这个城...
    夏淮阅读 1,046评论 0 0
  • 你总说毕业遥遥无期,转眼就各奔东西,笑着说以后还能再聚,谁又知道以后是多久。微博上说,好好保存你的毕业照吧,有些人...
    lecho_me阅读 1,768评论 0 0
  • 你打朦胧的睡意中走来 我种下一支馥郁芬芳的花朵 我看见满天的繁星闪烁 你说那一抹天边的拂晓之色 你撒满阳光在被遗忘...
    六月日色如烟阅读 1,917评论 6 32