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

Deselecting all Items hangs in assertion #8

Open
Oggerschummer opened this issue Mar 26, 2013 · 1 comment
Open

Deselecting all Items hangs in assertion #8

Oggerschummer opened this issue Mar 26, 2013 · 1 comment

Comments

@Oggerschummer
Copy link

* Just saw this might be a duplicate, sorry - newbie failure*

Hi,

just checked out this nice piece of code (thanks !) and ran into an issue.
I rely on the ability to deselect all segments in the segemented control.
For UISegmentedControl this is possible by setting the selectedSegmentIndex to -1.

URBSegmentedControl has some checks in

- (void)setSelectedSegmentIndex:(NSInteger)selectedSegmentIndex

that do not allow -1 as a value.

Tried the following change as a quick and dirty hack:

//NSParameterAssert(selectedSegmentIndex < (NSInteger)self.items.count && selectedSegmentIndex >= 0);
    //20130326 OGGERSCHUMMER fix for unselected control
    NSParameterAssert(selectedSegmentIndex < (NSInteger)self.items.count && selectedSegmentIndex >= -1);

    // deselect current segment if selected
    if (_selectedSegmentIndex >= 0)
        ((URBSegmentView *)[self segmentAtIndex:_selectedSegmentIndex]).selected = NO;
    if (selectedSegmentIndex>=0){//20130326 OGGERSCHUMMER Handle deselection of everything
        [self segmentAtIndex:selectedSegmentIndex].selected = YES;
    }

...

From what I see this does the trick, but I don´t know your code in detail yet.

Maybe you can check and adjust this.

Cheers,
Oggerschummer

@u10int
Copy link
Owner

u10int commented Mar 28, 2013

Thanks for the report, this is probably related to the other issue about selectedIndex. The original design was to always have an index selected which is the reason for the NSParameterAsset not allowing anything outside of the index range to be set. However, several users have reported an issue with deselecting all indexes so hopefully I can get around to implementing this fix this weekend.

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

2 participants