Monotouch: Force UITableView to recalculate height of each cell without reloading data

二次信任 提交于 2019-12-11 02:43:14

问题


I have a custom cell created using OwnerDrawnElement with autoresizeable UITextView in it. When text changed there should be appropriate layout redraw and cell height recalculation. The problem is how to preserve keyboard opened. There is a method inside UITableView - ReloadRows which actually helped me in some fashion. I can't call it for my cell because it is the first responder and can't I cant resign it. But when I call it for another cell my cell is getting resized as I wanted but I have unnecessary another cell redraw. So I wonder what method is called to relayout UITableView NOT reload data?! The same method is probable called when you scroll up and down, cells become visible and height is recalculated.

I've tried standard SetNeedsDisplay(), SetNeedsLayout(), ReloadInputViews(), LayoutSubviews(), but it didn't do the same. Maybe I need use them somehow differently. I've tried to call them for cell and whole tableview objects.

I've looked into ReloadRows method and found out that it calls some API stuff:

Messaging.void_objc_msgSendSuper_IntPtr_int(base.SuperHandle, UITableView.selReloadRowsAtIndexPathsWithRowAnimation_, nSArray.Handle, (int)withRowAnimation);

So it doesn't what method forces tableview to recalculate height of each cell without reloading data either.

Can you help me with that?


回答1:


Try to update cells frames, then call UITableView's empty update block:

tableView.BeginUpdates();
tableView.EndUpdates();


来源:https://stackoverflow.com/questions/14514391/monotouch-force-uitableview-to-recalculate-height-of-each-cell-without-reloadin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!