Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with setSelectedSegmentIndex:animated: #64

Open
viking2009 opened this issue Oct 19, 2013 · 1 comment
Open

problem with setSelectedSegmentIndex:animated: #64

viking2009 opened this issue Oct 19, 2013 · 1 comment

Comments

@viking2009
Copy link

I'm using old way for tracking changes (addTarget:action:forControlEvents:)

- (void)setSelectedSegmentIndex:(NSUInteger)index animated:(BOOL)animated {
    _selectedSegmentIndex = index;

    if(self.superview) {
        [self sendActionsForControlEvents:UIControlEventValueChanged];

sendActionsForControlEvents called even if selected segment not changed

@viking2009
Copy link
Author

this should solve the problem:

- (void)setSelectedSegmentIndex:(NSUInteger)index animated:(BOOL)animated {
    BOOL sendActions = (_selectedSegmentIndex != index);

     _selectedSegmentIndex = index;

     if(self.superview) {
        if (sendActions)
            [self sendActionsForControlEvents:UIControlEventValueChanged];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant