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

Value is not updated when change handler is called #55

Open
koloritcm opened this issue May 28, 2013 · 0 comments
Open

Value is not updated when change handler is called #55

koloritcm opened this issue May 28, 2013 · 0 comments

Comments

@koloritcm
Copy link

I'm calling a method that updates the UI depending on the current selected segment index. But the code doesn't work because the selectedSegmentIndex has not yet been updated when the handler is called.

You can see in the log from this statement that they are not in sync, selectedSegmentIndex is always one step behind:

self.segmentedControl.changeHandler = ^(NSUInteger newIndex) {
    NSLog(@"New index: %d, Current index: %d", newIndex, self.segmentedControl.selectedSegmentIndex);
    [self updateUI];
};

The regular event works fine and selectedSegmentIndex is updated when the below method is called. But I like blocks much better, too bad it doesn't work as good.

[self.segmentedControl addTarget:self action:@selector(segmentedControlChangedValue) forControlEvents: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