{"id":16948663,"url":"https://github.com/timoliver/topagerview","last_synced_at":"2025-04-11T20:12:44.999Z","repository":{"id":56923079,"uuid":"89450415","full_name":"TimOliver/TOPagerView","owner":"TimOliver","description":"A UIScrollView subclass that allows paged horizontal swiping with a re-use mechansim similar to UITableView.","archived":false,"fork":false,"pushed_at":"2019-08-22T01:38:59.000Z","size":276,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T20:12:40.188Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimOliver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-26T07:18:00.000Z","updated_at":"2023-05-04T13:09:47.000Z","dependencies_parsed_at":"2022-08-21T04:50:27.231Z","dependency_job_id":null,"html_url":"https://github.com/TimOliver/TOPagerView","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FTOPagerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FTOPagerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FTOPagerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimOliver%2FTOPagerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimOliver","download_url":"https://codeload.github.com/TimOliver/TOPagerView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473126,"owners_count":21109628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T21:51:53.516Z","updated_at":"2025-04-11T20:12:44.969Z","avatar_url":"https://github.com/TimOliver.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TOPagerView\n\u003e A `UIScrollView` subclass that allows paged horizontal swiping with a re-use mechansim similar to `UITableView`.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/timoliver/TOPagerView/master/screenshot.jpg\" style=\"margin:0 auto\" /\u003e\n\u003c/p\u003e\n\nOriginally developed in a time period where `UICollectionView` wasn't 100% feasible yet, `TOPagerView` is a view to streamline rendering fullscreen 'pages' of content in a horizontal layout, similar to the slideshow view in Photos.app.\n\nIt is built on the same architectural principles as `UITableView`, where a pool of page views are continually recycled via a delegate object as pages scroll on and off the screen.\n\nIn this day and age, it's definitely recommended to use `UICollectionView` instead of custom classes like this one, but there *may* still be cases where this sort of view might have value.\n\n# Features\n* Displays child views as full-screen pages that can be swiped left or right.\n* The ascending page direction can be changed from left-to-right, to right-to-left as needed.\n* Header and Footer accessory views can also be added as needed.\n* Provides APIs to randomly jump to specific page numbers.\n* The automatic page turning animation can be cancelled in response to user events to allow extremely fast navigation.\n\n# Requirements\niOS 7.0 and above\n\n# Installation\n## Manually\nDrag the folder `TOPagerView` into your Xcode project. Make sure `Copy Items if Needed` is checked to ensure a copy is imported into your Xcode project folder properly.\n\n## CocoaPods\n[CocoaPods](http://cocoapods.org) is a dependency manager that makes it simple to import and manage third party libraries in your projects.\n\nAdd the following to your `Podfile`:\n```\npod 'TOPageView'\n```\n\n## Usage\n`TOPagerView` behaves very similarly to `UITableView`. You can pre-register classes, or create new instances on demand.\n\nYou add `TOPagerView` to a view controller like most other views:\n\n```objc\n    self.pagerView = [[TOPagerView alloc] initWithFrame:self.view.bounds];\n    self.pagerView.scrollView.delegate = self; // The internal scroll view delegate can be publicly accessed if needed\n    self.pagerView.dataSource  = self;\n    self.pagerView.delegate    = self;\n    [self.view addSubview:self.pagerView];\n```\n\nBy default, displaying content is extremely straightforward. It's not even necessary to subclass `UIView`: \n\n```objc\n- (NSInteger)numberOfPagesInPagerView:(TOPagerView *)pageScrollView\n{\n    return 8;\n}\n\n- (UIView *)pagerView:(TOPagerView *)pagerView pageViewForIndex:(NSInteger)pageIndex\n{\n    UIView *view = [pagerView dequeueReusablePageView];\n    if (view == nil) {\n        view = [[UIView alloc] init];\n        view.backgroundColor = [UIColor whiteColor];\n    }\n\n    // Configure the view further\n    \n    return view;\n}\n```\n\nIf you want to display separate types of views in a single pager view, you can optionally add a string identifier in order to distinguish page views:\n\n```objc\n@interface MyView : UIView\u003cTOPagerViewPageProtocol\u003e\n@end\n\n@implmentation MyView\n\n+ (NSString *)pageIdentifier\n{\n   return @\"MyViewIdentifier\";\n}\n\n@end\n\n// ---\n\n@implementation MyViewController\n\n- (UIView *)pagerView:(TOPagerView *)pagerView pageViewForIndex:(NSInteger)pageIndex\n{\n    MyView *view = (MyView *)[pagerView dequeueReusablePageViewForIdentifier:[MyView pageIdentifier]];\n    if (view == nil) {\n        view = [[MyView alloc] init];\n        view.backgroundColor = [UIColor whiteColor];\n    }\n\n    // Configure the view further\n    \n    return view;\n}\n\n@end\n\n```\n\n# Why Build This?\n\nI started writing this library in 2013 (On my 27th birthday apparently!) as a replacement for the pager view I originally wrote in 2011 for [iComics](http://icomics.co).\n\nI wrote the original pager during the era of iOS 5, before `UICollectionView` was announced in 2012. I was still VERY new to iOS development in that time, and as such, the architecture of the original pager is 'not great'. Functional, but definitely not subscribing to the proper MVC architectural model.\n\nIn 2013, I was still gung-ho on supporting the original iPad (running iOS 5) so I wanted to avoid using `UICollectionView` as much possible. As such, I wrote this library as an eventual replacement, greatly cleaning up the design in the process.\n\nIt's now 2017, and we've long since reached the point where the original iPad and its immediate successors are long dead, and rolling your own `UIScrollView` subclass instead of taking advantage of `UICollectionView` is extremely questionable.\n\nAs such, I'm releasing this code more as an educational piece, more than something that should be used in production, but you're more than welcome to use it in your apps if you wish! :)\n\n# License\n\nThis library is licensed under the MIT license. Please see [LICENSE](LICENSE) for more details.\n\n# Credits\n`TOPagerView` was created by [Tim Oliver](http://twitter.com/TimOliverAU) as a component for iComics.\n\niPhone 5c device mockup by [Pixeden](http://pixeden.com). ![analytics](https://ga-beacon.appspot.com/UA-5643664-16/TOPagerView/README.md?pixel)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoliver%2Ftopagerview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimoliver%2Ftopagerview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoliver%2Ftopagerview/lists"}