GithubHelp home page GithubHelp logo

cemolcay / categorysliderview Goto Github PK

View Code? Open in Web Editor NEW
352.0 352.0 35.0 349 KB

slider view for choosing categories. add any UIView type as category item view. Fully customisable

License: MIT License

Objective-C 73.23% Ruby 26.77%

categorysliderview's People

Contributors

cemolcay avatar readmecritic 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

categorysliderview's Issues

Swift error with NSContiguousString frame

Hey, I'm having issues setting up the slider with swift.

     let listSlider = CategorySliderView.init(frame: CGRectMake(0 , 0, 60, self.view.frame.width),
            andCategoryViews: List.getAll(),
            sliderDirection: SliderDirection.Horizontal,
            categorySelectionBlock: { (categoryView: UIView!, index: Int) -> Void in
                print("index: \(index)")
        })

or

        let listSlider = CategorySliderView(sliderHeight: 60.0,
            andCategoryViews: List.getAll()) { (categoryView: UIView!, index: Int) -> Void in
                print("index: \(index)")
        }

Either way, I'm getting the error I'm getting below:

2016-01-24 18:18:34.220 CelebrityScore[84554:3132239] -[Swift._NSContiguousString frame]: unrecognized selector sent to instance 0x7f84b3d46770
2016-01-24 18:18:34.228 CelebrityScore[84554:3132239] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._NSContiguousString frame]: unrecognized selector sent to instance 0x7f84b3d46770'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000113111e65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000112b8adeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000011311a48d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000011306790a ___forwarding___ + 970
    4   CoreFoundation                      0x00000001131132d8 __forwarding_prep_1___ + 120
    5   CategorySliderView                  0x000000010f641c8a -[CategorySliderView addCategoryView:] + 618
    6   CategorySliderView                  0x000000010f641913 -[CategorySliderView initWithFrame:andCategoryViews:sliderDirection:categorySelectionBlock:] + 1603
    7   CelebrityScore                      0x000000010ee46b93 _TTOFCSo18CategorySliderViewcfMS_FT5frameVSC6CGRect16andCategoryViewsGSQGSaPSs9AnyObject___15sliderDirectionOSC15SliderDirection22categorySelectionBlockGSQFTGSQCSo6UIView_Si_T___GSQS__ + 499
    8   CelebrityScore                      0x000000010ee4588a _TFCSo18CategorySliderViewCfMS_FT5frameVSC6CGRect16andCategoryViewsGSQGSaPSs9AnyObject___15sliderDirectionOSC15SliderDirection22categorySelectionBlockGSQFTGSQCSo6UIView_Si_T___GSQS__ + 186
    9   CelebrityScore                      0x000000010ee3f039 _TFC14CelebrityScore20MasterViewControllercfMS0_FT9viewModelCS_17CelScoreViewModel_S0_ + 2153
    10  CelebrityScore                      0x000000010ee3f743 _TFC14CelebrityScore20MasterViewControllerCfMS0_FT9viewModelCS_17CelScoreViewModel_S0_ + 67
    11  CelebrityScore                      0x000000010ee39a1f _TFC14CelebrityScore11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 1663
    12  CelebrityScore                      0x000000010ee3a253 _TToFC14CelebrityScore11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 179
    13  UIKit                               0x000000011153e1f1 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
    14  UIKit                               0x000000011153f397 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
    15  UIKit                               0x0000000111545cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
    16  UIKit                               0x0000000111542e7b -[UIApplication workspaceDidEndTransaction:] + 188
    17  FrontBoardServices                  0x00000001183f7754 -[FBSSerialQueue _performNext] + 192
    18  FrontBoardServices                  0x00000001183f7ac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    19  CoreFoundation                      0x000000011303da31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    20  CoreFoundation                      0x000000011303395c __CFRunLoopDoSources0 + 556
    21  CoreFoundation                      0x0000000113032e13 __CFRunLoopRun + 867
    22  CoreFoundation                      0x0000000113032828 CFRunLoopRunSpecific + 488
    23  UIKit                               0x00000001115427cd -[UIApplication _run] + 402
    24  UIKit                               0x0000000111547610 UIApplicationMain + 171
    25  CelebrityScore                      0x000000010ee3b50d main + 109
    26  libdyld.dylib                       0x000000011490192d start + 1

How would you recommend to set up the slider in swift?

Updating Buttons

If the user needs updated buttons showing x followers each time the user enters his/hers profile and that x value is fetched async from the web in viewWillAppear, how can you then update the button with the value x when the callback comes in?
In other words, how can you update the buttons after they first have been laid out?

Thank you for your time
Alexander

Swift Code

Hi, I've been trying to translate this tiny part of code into Swift.. can someone help?

CategorySliderView *sliderView = [[CategorySliderView alloc] initWithSliderHeight:60 andCategoryViews:@[category1, category2, category3] categorySelectionBlock:^(UIView *categoryView, NSInteger categoryIndex) {
UILabel *selectedView = (UILabel *)categoryView;
NSLog(@""%@" cateogry selected at index %d", selectedView.text, categoryIndex);
}];

Setting backgroundColor

Hi,

I'm unable to set the backgroundColor of an initialized CategorySliderView. This code doesn't work and the view still has a yellow background, is there a trick to setting the background color or am I missing something?

[self.sliderView setBackgroundColor:[UIColor redColor]];

I found where this is hardcoded to yellow in the .m file, would you take a pull request to add setting the bgColor to the initWithFrame.... initializer like:

- (instancetype)initWithFrame:(CGRect)frame andCategoryViews:(NSArray *)categoryViews sliderDirection:(SliderDirection)direction categorySelectionBlock:(categorySelected)block withBackgroudColor:(UIColor *)bgColor;

EDIT:
I discovered that if I remove line 53: https://github.com/cemolcay/CategorySliderView/blob/master/CategorySliderView/CategorySliderView.m#L53
I'm able to set the backgroundColor in my instantiated CategorySlider. I'm happy to create a pull request to remove the [self.scrollView setBackgroundColor:[UIColor yellowColor]]; line and/or create an initializer. Let me know if you have a preference

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.