Git Product home page Git Product logo

dnscastrosegmentedcontrol's People

Contributors

designatednerd avatar getaaron avatar mandaris avatar rbarbera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dnscastrosegmentedcontrol's Issues

Cornet radius variable

Hello,

This isn't really a bug, but more of a feature request.
I noticed that you hardcoded the radius value. Why not just expose the divider a public property? This way we could personalize the radius ourselves:

CGFloat cornerRadius = (CGRectGetHeight(self.frame) / publicRadiusVariable);

The higher the value - the more square corners will get. I'd probably submit a PR, but I'm more of a Swift person and just afraid to mess things up :)

Add try/catch in dealloc

It's possible for the control to be deallocated without registering for KVO. When this happens, this code will throw an exception:

- (void)dealloc
{
    [self removeObserver:self forKeyPath:[self boundsKeyPath]];
}

Here's the ugly solution as suggested by NSHipster:

- (void) dealloc {
    @try {
        [self removeObserver:self forKeyPath:[self boundsKeyPath]];
    } @catch(NSException * __unused exception){}
}

Outline does not change when selecting programmatically

When called programmatically the selected outline does not move, only selected the icon changes selected color.

In my case the outline should have moved the the second icon.

programmaticSegmentedControl.setSelectedSegmentIndex(1, animated: true)

dnscastro

touchesMoved:withEvent: shouldn't call setSelectedSegmentIndex:animated:

The current implementation does this:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    // some stuff…

    [self setSelectedSegmentIndex:roundedSection animated:YES];
}

I believe most users will consider it unexpected if an app's state changes while they're still dragging their finger. Normally, it's safe to drag controls around on the screen, and nothing will take effect until the finger is lifted. For example, in Settings, a user can drag the Airplane Mode switch right and left, and Airplane Mode won't enable unless they lift their finger while the switch is enabled.

Instead, I believe this behavior should be in touchesEnded:, and touchesCancelled: should revert selectionView to its original state.

Wrong super methods called in touchesEnded: and touchesCancelled:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];
    [self touchesEndedOrCancelled];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];
    [self touchesEndedOrCancelled];
}

These methods both call touchesMoved: instead of their appropriate super method.

If this is intentional, can we document the reason?

Incorrect assert in layoutSubviews

From layoutSubviews:

if (!self.choices) {
    NSAssert(@"NO", @"Cannot setup with no choices set!");
}

However, @"NO" evaluates to YES, so the assert is never thrown.

I suggest we assert the actual condition:

NSAssert(self.choices, @"Cannot setup with no choices set!");

This would allow us to remove the conditional.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.