美文网首页iOS技能iOS DeveloperiOS开发
bug:viewcontroller添加UITableView使

bug:viewcontroller添加UITableView使

作者: 李小争 | 来源:发表于2015-12-08 15:55 被阅读429次

    遇到了这个问题,然后查找了 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使

        本文链接:https://www.haomeiwen.com/subject/ewpehttx.html