GithubHelp home page GithubHelp logo

mjnindexview's Introduction

iOS - MJNIndexView

MJNIndexView is a highly customizable UIControl which displays an alternative index for UITableView. I wanted to mimic the index designed by Jeremy Olson's Tapity for their Languages app. I think their idea of implementing index is brilliant and it is one of the best examples of great UX. I hope more apps are going to use similar indices instead of the generic ones.

Screenshot Screenshot Screenshot Screenshot

Youtube video

IMAGE ALT TEXT HERE

Example Code

@interface MJNIndexTestViewController () <MJNIndexViewDataSource>

@property (nonatomic, strong) MJNIndexView *indexView;
@property (nonatomic, strong) NSMutableArray *sectionArray;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation MJNIndexTestViewController

- (void)viewDidLoad
{
  [super viewDidLoad];

	// initialise tableView
	self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds]	[self.tableView registerClass:[UITableViewCell
	class]forCellReuseIdentifier:@"cell"];
	self.tableView.dataSource = self;
	self.tableView.delegate = self;
	self.tableView.showsVerticalScrollIndicator = NO;
	[self.view addSubview:self.tableView];

	// initialise MJNIndexView
	self.indexView = [[MJNIndexView alloc]initWithFrame:self.view.bounds];
	self.indexView.dataSource = self;
	self.indexView.fontColor = [UIColor blueColor];
	[self.view addSubview:self.indexView];
}

// two methods needed for MJNINdexView protocol
- (NSArray *)sectionIndexTitlesForMJNIndexView:(MJNIndexView *)indexView
{
	return sectionArray;
}

- (void)sectionForSectionMJNIndexTitle:(NSString *)title atIndex:(NSInteger)index;
{
	[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 	inSection:index] atScrollPosition: UITableViewScrollPositionTop 	animated:NO];
}
.
.
.
@end

Usage

Only two files are required for using MJNIndexView: MJNindexView.h & MJNIndexView.m. Copy both of them into your Xcode Project. Make sure to include QuartzCore framework in your target.

Your UIViewController must implement MJNIndexViewDataSource protocol methods. The first one of them is needed to provide the index with all section titles. The second one is needed to provide UIViewController with a title or index number selected by a user.

You can customize the look and behaviour of MJNIndex by tweaking more than 20 parameters. You can experiment with the most of them in the demo app.

If you want to change items in the index or most of its parameters after the MJNIndexView was added to the superView you should use the method – (void)refreshIndexItems to recalculate every item position, size etc.

To do

• Improve a curtain fade (it could behave strange when you use very large value for the right margin).

• Improve performance on older devices

• Cocoapod

Credits

If you use this control in your app, please add some credits.

License

MIT License

Copyright (c) 2013 Mateusz Nuckowski (http://mateusz.nuckowski.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mjnindexview's People

Contributors

matthewfx avatar yesjun avatar

Watchers

James Cloos avatar 开水白菜 avatar

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.