JTrackView is a UI component similar in nature to a UITableView which allows for scrolling a list of items in a horizontal manner rather than a vertical manner such as with a UITableView. It is intended to be very lightweight, and performance has been measured on an iPhone 4 at a worst case of 55 fps with a non-trivial set of opaque subviews. In other words, it scrolls like butter.
This view uses ARC, and weak links, so it will work on iOS 4.x, but you'll need PLWeakCompatibility, or iOS 5.x.
To use JTrackView, add these files to your project, ensure the JTrackView.m and JTrackViewCell.m files are in your compile build phase.
In your view controller, add a reference to the trackView, connect it to a UIScrollView in a nib or storyboard (remembering to change the class name to JTrackView) as an outlet (should you choose to do it this way), or create it manually by calling -initWithFrame:. Set the data source on the trackview to your controller, and implement JTrackViewDelegate however you need to.
For instance, your implementation may look like this:
@interface FantasticViewController : UIViewController
@property (nonatomic, strong) IBOutlet JTrackView* trackView;
@end
@implementation FantasticViewController
@synthesize trackView = _trackView;
/* ... */
- (void)numberOfPagesInTrackView:(JTrackView*)trackView
{
return 5;
}
- (CGFloat)pageWidthInTrackView:(JTrackView*)trackView;
{
return CGRectGetWidth(self.trackView.bounds);
}
- (JTrackViewCell*)trackView:(JTrackView*)trackView cellForPageAtIndex:(NSUInteger)index
{
static NSString* identifier = @"TrackCell";
// When you dequeue a cell, you will always, always get back a good object you can use,
// even if there are no cells for recycling available, we'll create one for you.
JTrackViewCell* cell = [trackView dequeueReusableCellWithIdentifier:identifier];
/* do your stuff */
return cell;
}
/* ... */
@end
You should now have 5 pages of cells.
Easy to integrate, does what it says and it's free. What's not to like? (I haven't looked at the code, so ignore that rating.)
:)
Very easy to use, and very flexible
Questions & Comments