简体   繁体   中英

UITableViewCell not resizing for UIView subview

I added this library called KSTokenView which is a tokenizer like NSTokenField . This UIView subclass was added to the UITableViewCell . Connections were made with all the 4 sides of this UIView to the content view. Now as I type into the view and the size changes, there is a delegate method for change of frame.

Using the frame change for that, I need to resize my tableviewcell and in turn the tableview also.

In the view controller for the table view, I am giving an estimated row height of UITableViewAutomaticDimension . I am currently doing tableView.beginUpdates and tableView.endUpdates on change of frame.

What is the correct way?

I think changing the frame is not the right way to do it (if you're using autolayout). You can set a height constraint to your view and update its constant instead, in the same place you update the frame.

Update

I am giving an estimated row height of UITableViewAutomaticDimension

You shouldn't set estimatedRowHeight to be UITableViewAutomaticDimension . It should be an estimated average number of your cell height and rowHeight should be UITableViewAutomaticDimension .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM