ios 8 tableview reloads automatically when view appears after pop

后端 未结 2 1746
时光取名叫无心
时光取名叫无心 2021-01-16 08:04

I have a table view, onclick of 7th row, I push another view. Then when I come back using pop, tableview is reloaded automatically in ios8. It does not happen is ios 7.

2条回答
  •  长发绾君心
    2021-01-16 08:52

    I had the same problem and this is how I fixed it:

    According to the Apple docs:

    UITableView overrides the layoutSubviews method of UIView 
    so that it calls reloadData only when you create a new 
    instance of UITableView or when you assign a new data source.
    

    In my case I was setting the table view's dataSource to nil in viewWillDisappear: and setting it back to self in viewWillAppear: thus causing the data to be reloaded.

    The 'automatic' reload went away when I moved the dataSource assignment to viewDidLoad

    Hope this helps!

提交回复
热议问题