views:

294

answers:

1

So I have a nicely working UITableView consisting of 3 rows (each including and image, and a varying number of text fields).

Now the 4th row has a UISegmentedControl. As soon as I added it, the UITableView lags/jumps/skips. When I take it away again, everything is smooth.

How can I add the UISegmentedControl and still have smooth scrolling?

A: 

Had a similar problem. After the segmented control goes out of view, scrolling back to it is choppy. The problem could be the initialization.

First check if you use the "dequeueReusableCellWithIdentifier" correctly (maybe you missed giving your custom cell a unique ID ?)

Second check if you don't do removeAllSegments and insertSegmentWithTitle each time in cellForRowAtIndexPath. Add some int to your custom cell to tell you if it is a new cell or a reused cell with a certain number of segments. Then after you "dequeueReusableCellWithIdentifier" if the cell has the exact number of segments no clearing and adding is needed.

In my case I did the checked the first but not the second which made my scrolling lag. It seems that the segment clearing and adding is a costly operation.

Hope this helps.

EasyGoing