rs / SDSegmentedControl

A drop-in remplacement for UISegmentedControl that mimic iOS 6 AppStore tab controls
MIT License
1.2k stars 181 forks source link

Selection Indicator and its animation not working properly when control is subview of viewForHeaderInSection #37

Open inPhilly opened 11 years ago

inPhilly commented 11 years ago

I made a comment on issue 18, asking for it to be reopened, but I will also post it here new in case those do not get looked at. As in issue 18, I am also using SDSegmentedContol in viewForHeaderInSection; if you return the control itself as the entire view, there is no problem; but if you add it as a subview to a view (that will also contain other components) - the problem remains; specifically, when there is action on the SDSegmentedContol, I have it reload the entire tableview; SDSegmentedContol itself is a PART of the tableview in viewForHeaderInSection; viewForHeaderInSection gets called and while SDSegmentedContol does not get recreated, it gets added to the view that is returned for the header in the section. This is how I MUST do this to achieve the tableview effect that I need. So each time a 'segment' is selected, the tableview is reloaded and this control is added to the viewForHeaderInSection, and the arrow fails to animate properly - it does not move to the correct segment. If I do the same thing with a regular UISegmentedControl, it works perfectly.

inPhilly commented 11 years ago

Calling [self.tableview reloadData] on a delay (with performSelector) in the target action for the control seems to do the job, for now at least. I will try to post if I find anything different.

fprosper commented 11 years ago

Absolutely true, I confirm what @mommyme wrote, both the issue and the workaround.