Latest 0.0.3
Homepage https://github.com/tonyzonghui/UIKitHelper
License MIT Copyright (C) 2013 Zhang Zonghui

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.

Platforms ios , requires ARC
Authors

UIKitHellper is a collection of UIKit classes that makes some common view behaviors easily to implement, like tap background to hide keyboard, infinite scroll view, etc.


1. ISPageScrollView

Description

ISPageScrollView is a UIScrollView subclass optimised for huge number of pages display. It uses lazy-loading mechanism to maintain only the previous few pages and the next few pages in order to minimize the memory usage.

Properties:

id dataSource: Like UITableViewDataSource, it asks its dataSource object for views displayed in each page.

NSInteger numberOfReusablePages: number of pages maintanined in memory. This number should be an odd number (e.g: 5 = current displayed page + 2 pages in front + 2 pages after)

NSInteger numberOfPages: number of total pages

NSMutableDictionary readonly scrollViewAvailablePages: this is the dictionary that stores the views of the pages in memory. The keys for the dictionary are NSNumbers for page index. The values for each key is an UIView object.

Usage

It can be created in xcode like UIScollView or can be created programatically.

ISPageScrollView *pageScrollView = [[ISPageScrollView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
pageScrollView.dataSource = self;
pageScrollView.numberOfPages = 10;
pageScrollView.numberOfReusableViews = 5;

[pageScrollView displayPage:0];

You also need to implement the datasource methods like UITableView in order for the page scroll view to know what to display

@interface ViewController () <ISPageScrollViewDataSource>

@end

@implementation ViewController
…

#pragma mark - ISPageScrollViewDataSource

- (UIView *)viewForScrollView:(UIScrollView *)scrollView Page:(NSInteger)pageIndex
{
    UIView *pageView = [[UIView alloc] initWithFrame:scrollView.frame];
    pageView.backgroundColor = [UIColor colorWithRed:pageIndex * 10 / 255.0 green:pageIndex * 10 / 255.0 blue:pageIndex * 10 / 255.0 alpha:1.0];
    return pageView;
}

…
@end

2. AutoHideKeyboardViewController

Description

AutoHideKeyboardViewController is a subclass of UIViewController which enables the tap background to hide keyboard behavior.

Usage

There are only 2 steps to make your viewcontroller hide keyboard on background tapped.

Step 1: Make your viewcontroller a subclass of AutoHideKeyboardViewController instead of UIViewController

#import "AutoHideKeyboardViewController.h"

@interface ViewController : AutoHideKeyboardViewController

Step 2: If you have any UITextView or UITextField in your page, set their delegate to your viewcontroller.

That’s it!


3. AutoHideKeyboardTableViewController

The usage and the behaviour is the same as AutoHideKeyboardViewController. This is for UITableView to implement ‘tap background to dismiss keyboard’ behavior.

License


UIKitHelper is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "UIKitHelper",
    "version": "0.0.3",
    "summary": "UIKitHellper is a collection of UIKit classes that makes some common view behaviors easily to implement.",
    "description": "UIKitHellper is a collection of UIKit classes that makes some common view behaviors easily to implement, like tap background to hide keyboard, infinite scroll view, etc.",
    "homepage": "https://github.com/tonyzonghui/UIKitHelper",
    "license": {
        "type": "MIT",
        "text": "               Copyright (C) 2013 Zhang Zonghuinn               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:nn               The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.nn               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.n               n"
    },
    "authors": {
        "Zhang Zonghui": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tonyzonghui/UIKitHelper.git",
        "tag": "0.0.3"
    },
    "platforms": {
        "ios": null
    },
    "source_files": "UIKitHelper",
    "requires_arc": true
}

Pin It on Pinterest

Share This