Code Monkey home page Code Monkey logo

ehhorizontalselectionview's Introduction

EHHorizontalSelectionView

This is extension for presenting horizontal lists of items (horizontal tableview)

Installation

CocoaPods

To install EHHorizontalSelectionView using CocoaPods, please integrate it in your existing Podfile, or create a new Podfile:

target 'MyApp' do
  pod 'EHHorizontalSelectionView'
end

Then run pod install.

Manual

Add files from EHHorizontalSelectionView to your project

Usage

#import <EHHorizontalSelectionView/EHHorizontalSelectionView.h>

You can use EHHorizontalSelectionView as outlet in your xib or storyboard

@property (nonatomic, weak) IBOutlet EHHorizontalSelectionView * hSelView;

Default style of table is with EHHorizontalViewCell cells. To change default behaviour you need register another cell class or cell nib. Custom cell must subclassed from EHHorizontalViewCell.

For example cell types with animated selection:

[_hSelView registerCellWithClass:[EHHorizontalLineViewCell class]];

[_hSelView1 registerCellWithClass:[EHRoundedHorizontalViewCell class]];

or your custom cell:

[_hSelView2 registerCellNib:[UINib nibWithNibName:@"MyCustomCellNib" bundle:nil] withClass:[EHHorizontalViewCell class]];

Setting delegate:

_hSelView1.delegate = self;

Delegate needs for getting data for selection view:

- (NSUInteger)numberOfItemsInHorizontalSelection:(EHHorizontalSelectionView*)hSelView
- (NSString *)titleForItemAtIndex:(NSUInteger)index forHorisontalSelection:(EHHorizontalSelectionView*)hSelView

and for receiving selection event:

- (void)horizontalSelection:(EHHorizontalSelectionView * _Nonnull)hSelView didSelectObjectAtIndex:(NSUInteger)index;

Tips

In case of "the behavior of the UICollectionViewFlowLayout is not defined because:" may help:

self.automaticallyAdjustsScrollViewInsets = NO;

Customization

IB customization

After 1.3.0 you can use IB to change selection view apperance. There was presented a set of properties allowing to change the appearance of the view. EHHorizontalSelcetionView is now marked as IBDesignable and you can see customization on your xib or storyboard

Color

You can change default tint color for cell of selected type

[EHHorizontalLineViewCell updateTintColor:[UIColor colorWithHex:0x00c264]];

You can subclass cell of that type and override method + (UIColor * _Nonnull)tintColor;

+ (UIColor *)tintColor
{
  return [UIColor redColor];
}

Or you can change tint color for chosen selection view

    [_hSelView2 setTintColor:[UIColor colorWithHex:0xff46c7]];

Fonts

Change default appearance

[EHRoundedHorizontalViewCell updateFontMedium:[UIFont boldSystemFontOfSize:15]];
[EHRoundedHorizontalViewCell updateFont:[UIFont systemFontOfSize:15]];

Change for chosen selectionView

[_hSelView3 setFont:[UIFont systemFontOfSize:17]];

Additional width for cell (inset)

Change default appearance

[EHHorizontalLineViewCell updateCellGap:20];

Change for chosen selectionView

[_hSelView3 setCellGap:15.f];    

Line height (for EHHorizontalLineViewCell)

[EHHorizontalLineViewCell updateColorHeight:2];

Author

Danila Gusev

[email protected]

License

Usage is provided under the MIT License. See LICENSE for full details.

ehhorizontalselectionview's People

Contributors

joshr604 avatar josshad avatar syky27 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

ehhorizontalselectionview's Issues

Unable to register in Swift 3

I am getting this error when using swift 3

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle
</Users/soomroshahid/Library/Developer/CoreSimulator/Devices/608B89C1-6BB2-4486-B747-4E8BCD976E8B/data/Containers/Bundle/Application/A0656148-9E39-4907-8D1B-3B965E8ACA70/SmartMart.app/Frameworks/EHHorizontalSelectionView.framework> (loaded)' with name 'EHHorizontalViewCell''

Selected/Non-Selected Font Colors should not be forced to be the same

Depending on the background color for the control and the background color for the selected view, selected/non-selected font colors, in several cases, should not be forced to be the same. For example, I use a white control background and a dark selected background. So it would make most sense for me to use a dark font color for the Non-selected sections and a white font color for the selected section. However, there is currently no way to do this with the control.

Interfacebuilder failed to render

Hi,
i have a Problem with the current version.
The Interfacebuilder can't render the ViewController where the EHHorizontalSelectionView is in.
I tried removing the class from the IB Object and it worked again.
Please help.
kind regards, Felix

pathToStoryboard/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for ViewController (XXX-XXX-XXX): Failed to load designables from path (null)

Line View Cell Selection

When using the LineViewCell and you have a cell selected at beginning of the SelectionView and then scroll to the far cell that was off-screen and select the far cell and scroll back to the first cell both will appear to be selected.

This is due to the fact that the cells are reusable and when a cell is selected, and scrolled off-screen, in the 'didSelectItemAtIndexPath' the collection view is unable to find the cell at the '_selectedIndex' since it is now offscreen and dequeued when using '[collectionView cellAtIndex..]'

A quick solution I came up with was to add a '_selectedCell' variable of type EEHorizontalViewCell in the EHHorizontalSelectionView class which will always give us access to the currently selected cell.

I can do a pull request for my code if you'd like.

PS. Thanks for sharing your selectionview :)

Creating EHHorizontalSelectionView programmatically?

Hi Danila, I am creating EHHorizontalSelectionView programmatically, means I don't have a storyboard or a XIB in my entire project. I am getting this exception when doing it. Can you help me to sort out what I am doing wrong?

2016-09-14 20:27:39.887 EHHorizontalSelectionViewExample[6606:203316] *** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UICollectionView.m:3994

2016-09-14 20:27:39.892 EHHorizontalSelectionViewExample[6606:203316] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier EHHorizontalLineViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

This is what I am doing:

hSelView4 = [[EHHorizontalSelectionView alloc] init];
hSelView4.frame = CGRectMake(0, 400.0f, 320.0, 60.0f);
hSelView4.delegate = self;
[self.view addSubview:hSelView4];

[hSelView4 registerCellWithClass:[EHRoundedHorizontalViewCell class]];

I have also implemented it's datasource methods.

Issue in Swift

I was added all three methods in my swift view controller

screen shot 2016-09-21 at 4 17 46 pm

func numberOfItemsInHorizontalSelection(hSelView: EHHorizontalSelectionView) -> UInt {

}

func titleForItemAtIndex(index: Int, forHorisontalSelection hSelView: EHHorizontalSelectionView) -> String? {

}

func horizontalSelection(hSelView: EHHorizontalSelectionView, didSelectObjectAtIndex index: UInt) {

}

getting error for protocol does not confirmed.

please help me.

Thanks.

View not center when useDynamicSize is NO

I want all tab have same size so I setting useDynamicSize to NO and change size of view in xib, it work well but have problem, space is left not equal with the right like image.
Please help me change it to center.
Thanks.
Tab not center

One more question: How I can change space between two item?

small bug

the needCentred does not work because the + (void)updateNeedCentered:(BOOL)needCentered saves the value using the needCentered key and the getter is needCentred.

reloadData() don't work on a Swift project

I've a simple list of items that change during time, but reloadData() don't change titles.
I've no errors but the datasource list remain always the same as started. I've try to take a look through breakpoints and the array changed but the list inside the EHHorizontalSelectionView "collectionView" don't change.

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.