Current setting
I have a custom cell loaded from xib where most of its space is covered by a UITextview. Also this cell can have several text views. And in this cell there are several more elements (one UIView + 2 UILabels).
Problem
I tried to remove all of these views and delays, even if I only have one text view. In addition, the lag occurs only for the first time. Later, when I scroll down and run to another cell with the text in it, the lag does not occur at all.
Additional Information
The thing with this custom cell is that the text view is added to UIStackView. At the beginning, stackview is empty because I do not know (at development time) how many text views can / should be there.
I know that this is another thing that can affect performance, but I solved it (I think it is the best way possible) by checking how many text views were already found in the stackview array arrangedSubviewswhen the cell was deleted, and based on this information I just add or I hide the views appropriately (instead of destroying and re-creating the required number of text views each time).
I tried using the "Tools", but I did not notice that any of my classes took CPU time, but some method calls UIKitcaused by the infrastructure inside are the reason for this ... If necessary, I can post a screenshot, but I think that this is not relevant, because they seem like ordinary system and infrastructure calls. Plus I'm testing the iPad 2: D, so maybe this is the thing (I need to optimize the app for slow devices).
However, I think I can somehow optimize it?
The MyCell class is pretty simple (pseudo code):
class MyCell:UITableViewCell{
func configure(data:SomeData){
self.addOrHideViewsIfNeeded()
}
private func addOrHideViewsIfNeeded(){
}
}
In addition, the lag is more noticeable in the Debug version compared to the Release version, which makes sense, but it is still noticeable.