vlasov / CCBottomRefreshControl

MIT License
319 stars 77 forks source link

AutoLayout crash #33

Open quba88 opened 7 years ago

quba88 commented 7 years ago

"NSLayoutConstraint for (null): Constraint must contain a first layout item" line 222: UITableView *tableView = self.brc_context.fakeTableView; is nil

meilbn commented 7 years ago

I got same issue when i used in a UITableViewController, as a UISearchController's results controller.

I think, because a UITableViewController's tableView doesn't have a superView, so [self brc_insertFakeTableView]; (L305) were not called., see Issue 11 And than, the tableView will dealloc, because context.fakeTableview is weak property.

By the way, you can use in UIViewController which has a UITableView, as same as Demo, it will be all right.

And, needs be set after tableView added to superView, if not, refreshControl were not showing.

quba88 commented 7 years ago

I use these with uicollectionView. I created two kind of app, with and without storyboard. Without storyboard works fine. ok thx for advice

Reiszecke commented 7 years ago

Moving my code to - (void)viewDidAppear:(BOOL)animated fixed it for me. I thought viewDidLoad would be sufficient but apparently it was not haha

EDIT: The table is part of a Master-Detail Application and now the exception is thrown when going back from the Detail to the Master. It looks like the tableView.bottomRefreshControl object is NULL. Any ideas?

pavithra123456 commented 6 years ago

Auto layout Crashing when switching between tabs .
NSLayoutConstraint for (null): Constraint must contain a first layout item" Any ideas?

meilbn commented 5 years ago

Setting bottomRefreshControl after you added tableView to view and set the layout constraint of the tableView:

self.view.addSubview(tableView)
tableView.snp.makeConstraints { (make) in
    make.top.equalTo(headerView.snp.bottom)
    make.left.bottom.right.equalToSuperview()
}

tableView.addBottomRefreshControl(target: self, selector: #selector(loadMoreAction))
meilbn commented 5 years ago

Update: In UITableViewController, it's still crash, move to UIViewController or using another framework, like: MJRefresh