Search code examples
iosuicontrol

HMSegmentedControl how to refresh its title


I'm using HMSegmentedControl in my application. I created a HMSegmentedControl instance in view controller A, then jumped to view controller B to collect data, like this: [self presentViewController:vc animated:YES completion:nil];

Then I went back to view controller A and changed the titles of HMSegmentedControl according to the values from view controller B. I used setSectionTitles: to do the job. The titles did not refresh until I clicked one of them, but I want it refresh immediately. How to do it?

I've tried self.view setNeedsDisplay but did not work.


Solution

  • setNeedsDisplay should do what you need. You just need to call it on the segmented control, not the view controller's view.

    [segmentedControl setNeedsDisplay];