Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am building an app which includes a Chat. When sending/ receiving messages that chat appears at the top of the other chats (like in all chat apps e.g Instagram, WhatsApp, ...).

Imaging having 3 chats, with person a, b and c, displayed in that specific order. If now, person c messages you, that specific chat cell is displayed on top of the other cells, due to it being the most recent message you sent/ received. I have implementet this with a single real time listener from firebase. If i now receive this message from person c, while i am not on the screen which displays the overview of all the messages, the tableview is told to reorder itself while not being visible, displaying this error: 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.

Everything works perfectly fine, but still i am not sure if this is the correct way to reload not only the tableview but controllers in general, if they are not visible. A more smooth solution would only update the content of the tableview (controllers in general) if they are visible/ layouted again.

question from:https://stackoverflow.com/questions/65952735/reload-uitableview-controllers-in-general-while-not-in-view-hierarchy

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
352 views
Welcome To Ask or Share your Answers For Others

1 Answer

another possible solution is reload the table in viewDidAppear(), so when ever the user open the overview page it will update.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...