• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

100grams/HGPageScrollView: UIScrollView for iPhone with horizontal paging like m ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

100grams/HGPageScrollView

开源软件地址(OpenSource Url):

https://github.com/100grams/HGPageScrollView

开源编程语言(OpenSource Language):

Objective-C 100.0%

开源软件介绍(OpenSource Introduction):

Page Scroll View.#

An extension of iOS UIScrollView that allows scrolling of multiple pages, like mobile Safari tab viewer.

HGPageScrollView uses a similar methodology to UITableView. It defines both a dataSource and a delegate, which its client can implement. At the very least HGPageScrollView expects its dataSource to provide HGPageViews to display.

Like UITableView, HGPageScrollView provides a way to improve performance by reusing pages. It maintains a queue of pages that the data source has marked for reuse. A page is marked for reuse by assigning a value to its reuseIdentifier.

Features

Scrolling horizontally through multiple views

In its basic form, HGPageScrollView shows a stack of pages, horizontally scrollable when in DECK mode (see Selection / Deselection below), where each page is a single view derived from HGPageView. The view itself is created by the data source and must be provided to HGPageScrollView in pageScrollView:viewForPageAtIndex:.

Selection / Deselection of views (aka View Modes)

HGPageScrollView has two distinct view modes:

  1. HGPageScrollViewModePage, in which the (selected) page is shown in full screen, along with its title header view.
  2. HGPageScrollViewModeDeck, in which pages can be scrolled horizontally. In this mode each page is scaled down to 60% of its original size.

Moving between the two view modes is implicit and occurs after calling selectPageAtIndex:animated: and deselectPageAnimated:.

Custom Page Headers

HGPageScrollView data source can provide custom header views to replace the default ones (seen in the exaple). A Header view is expected to have a title and a subtitle labels. The customization refers to the look and feel (size, colors etc.) of the header view.

Events

HGPageScrollView provides events to its delegate on scrolling, dragging selection and deselection of pages.

Advanced View Hierarchy (in combination with UINavigationController)

A more advanced use case, also demonstrated in this sample project, is when the page added to the page scroller actually belongs to a viewController which is part of a UINavigationController navigation stack. Doing so allows to create a rich and powerful view-hierarchy.

Inserting / Deleting / Reloading pages

HGPageScrollView supports insertion, deletion and reloading of one or more pages:

  • (void)insertPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated;

  • (void)deletePagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated;

  • (void)reloadPagesAtIndexes:(NSIndexSet *)indexes;

Animating page insertion/deletion will only take effect if it is done within the visible page range.

Requirements

  • iOS 4.3 or later (Original sample project was created with Xcode 3.2.6, iOS SDK 4.3 GM Seed) EDIT 9 May 2012: added compatibility with iOS 5.1.

Usage

Import HGPageScrollView folder into your project.

In your ViewController's initialization code, e.g. in viewDidLoad, instantiate HGPageScrollView from its associated NIB file, as follows:

HGPageScrollView *pageScrollView = [[[NSBundle mainBundle] loadNibNamed:@"HGPageScrollView" owner:self options:nil] objectAtIndex:0];

[self.view addSubview:pageScrollView];

Declare your view controller as HGPageScrollViewDataSource and optionally as HGPageScrollViewDelegate implement at the very least the required method in this protocol: pageScrollView:viewForPageAtIndex:

You can extend HGPageView by deriving from it, or as shown in the sample project, define your custom view.xib and set it's top level item to be HGPageView class. Then simply load your view using NSBundle's loadFromNib:owner:options. Make sure to define a reuseIdentifier for your view in order to improve performance.

Known limitations

  • Does not support landscape orientation. If you're up for the challenge of adding this support, let me know...

License

HGPageScrollView is released under MIT License.

Please report bugs/issues to help improve this code.

Any suggestions and/or code to help improve this source will be much appreciated.

Thanks!

endorse

Did you find this project helpful? Please endorse me... (It's free)




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
IronPans/bee-mobile: UI Components for React.发布时间:2022-08-30
下一篇:
leeenx/mobile-swiper: 移动端左右切换幻灯片组件发布时间:2022-08-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap