[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <FLTableView: 0x14384fe00; baseClass = UITableView; frame = (0 12; 390 741); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x280689c80>; layer = <CALayer: 0x280863b00>; contentOffset: {0, 0}; contentSize: {390, 769.33333333333326}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <ReleaseSupplyVC: 0x14310dfc0>>
刷新UITableView的時(shí)候祖秒,出現(xiàn)了類似的警告舟奠,出現(xiàn)這個(gè)問(wèn)題的原因是:要刷新的cell,當(dāng)前沒(méi)有出現(xiàn)在視圖中沼瘫,就已經(jīng)刷新了。
比如我出現(xiàn)的問(wèn)題是在setter方法里刷新的
#pragma mark - setter && getter
- (void)setClassifyModel:(ClassifyModel *)classifyModel {
_classifyModel = classifyModel;
self.model.productId = [classifyModel.classId integerValue];
self.model.classifyId = classifyModel.classifyId;
self.model.mdName = classifyModel.classifyName;
[self.tableView reloadRow:1 inSection:0 withRowAnimation:UITableViewRowAnimationNone];
}
但此時(shí)控制器的view都沒(méi)有顯示湿故。所以報(bào)了類似警告膜蛔。
修改的方法就是把刷新的時(shí)機(jī)調(diào)整到
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//刷新放在 set 方法里時(shí)機(jī)過(guò)早,會(huì)報(bào)錯(cuò)墅茉,調(diào)整到這里 ----》品類
[self.tableView reloadRow:1 inSection:0 withRowAnimation:UITableViewRowAnimationNone];
}
或者是
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}