Coder Social home page Coder Social logo

dymrollingbanner's Introduction

DYMRollingBanner

DYMRollingBanner is a clean and easy-to-use banner rolling control for your app's homepage screen which need to show some rolling banners.

DEMO Gif

Why

Why do I write this ? Well...actually, I've been searching for a scrolling banner view at github for a while, but no luck since some of the code I found are too old to support Autolayout, others don't scrolls infinitely... none of them satisfied me. Then, I decided to do it myself, to write a good one...and here you go...

Features

  • Infinite scrolling, which mean it shows banners/images in a infinite loop.
  • Can scroll automatically, the intervals and the direction of the scrolling is configurable.
  • Supports both local and remote images.
  • Placeholder image is customizable, Remote image fetch method is also cusomizable.
  • Paused on dragging and resumes on releasing when it's auto rolling.
  • Have a memory cache which makes it lightning fast and less memory consuming.
  • Block based event handling.
  • 100% compatible with AutoLayout.
  • Writen with clean code and very easy to use.

Installation

(from CocoaPods)

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like DYMRollingBanner in your projects. Simply add the following line to your Podfile:

pod 'DYMRollingBanner', '~> 2.1.7'

(direct installation)

Just copy these source files into you project:

  • DYMRollingBannerVC.h
  • DYMRollingBannerVC.m
  • DYMBannerVC.h
  • DYMBannerVC.m
  • DYMBannerPool.h
  • DYMBannerPool.m

Usage

Unlike many other banner scrolling controls, DYMRollingBanner doesn't use UIScrollingView or its subclasses UITableview or UICollectionView, instead it take full advantage of UIPageViewController which is natually an INFINITE controller.

To integrate DYMRollingBanner, firstly, you need to copy the assciated files into your project, and import DYMRollingBannerVC.h file:

#import <DYMRollingBanner/DYMRollingBannerVC.h>

Secondly, Create a DYMRollingBannerVC object.

DYMRollingBannerVC      *_rollingBannerVC;

_rollingBannerVC = [DYMRollingBannerVC new];

Then, add the DYMRollingBannerVC object as the child view controller of the host controller.

[self addChildViewController:_rollingBannerVC];
[self.view addSubview:_rollingBannerVC.view];
    
    // The code below lays out the _rollingBannerVC's view using Masonry
    [_rollingBannerVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.and.right.equalTo(self.view);
        make.height.equalTo(@200);
    }];
    
 [_rollingBannerVC didMoveToParentViewController:self];

Finally, feed it with you image URLs or UIImage object:

        // setup the rolling images
        _rollingBannerVC.rollingImages = @[@"http://easyread.ph.126.net/G8GtEi-zmPQzvS5w7ScxmQ==/7806606224489671909.jpg"
                             , @"https://c2.staticflickr.com/4/3345/5832660048_55f8b0935b.jpg"
                             , @"http://epaper.syd.com.cn/sywb/res/1/20080108/42241199752656275.jpg"
                             , [UIImage imageNamed:@"001"]
                             , [UIImage imageNamed:@"002"]
                             ];
                             
        // Start auto rolling (optional, default does not auto roll)
        [_rollingBannerVC startRolling];

And you are good to go!

You can also do many customizations to it (they are optional):

        // Set the inteval for rolling (optional, the default value is 1 sec)
        _rollingBannerVC.rollingInterval = 5;
        
        // Set the placeholder image (optional, the default place holder is nil)
        _rollingBannerVC.placeHolderImage = [UIImage imageNamed:@"default"];
        
        // Define the way how you load the image from a remote url
        [_rollingBannerVC setRemoteImageLoadingBlock:^(UIImageView *imageView, NSString *imageUrlStr, UIImage *placeHolderImage) {
            [imageView sd_cancelCurrentImageLoad];
            [imageView sd_setImageWithURL:[NSURL URLWithString:imageUrlStr] placeholderImage:placeHolderImage options:SDWebImageProgressiveDownload];
        }];
        
        // Add a handler when a tap event occours (optional, default do noting)
        [_rollingBannerVC addBannerTapHandler:^(NSInteger whichIndex) {
            NSLog(@"banner tapped, index = %@", @(whichIndex));
        }];
        
        // If 'YES', the auto scrolling will scroll to the right
        vc.isAutoScrollingBackward = YES;

Associated Classes

  • DYMRollingBannerVC is the view controller which rolls a group of banner images.
  • DYMBannerVC is the host view controller of each image, it's internally used by the DYMRollingBannerVC.
  • DYMBannerPool is the memory pool from which you dequeue a banner from, it's internally used by the DYMRollingBannerVC.

Contributing to this project

If you have feature requests or bug reports, feel free to help out by sending pull requests, or contact [email protected].

Credits

DYMRollingBanner is brought to you by Yiming Dong.
Follow me or ask questions or just say Hi! at Twitter : @dymx101

Logo

dymrollingbanner's People

Contributors

dymx101 avatar yeahdongcn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dymrollingbanner's Issues

Suddenly crash with warning from _UIQueuingScrollView

Hi, I'm using this framework in my project, it works nice until I found the below issue:

*** Assertion failure in -[_UIQueuingScrollView _didScrollWithAnimation:force:], /SourceCache/UIKit/UIKit-2372/_UIQueuingScrollView.m:778

I search the google with same problem here: http://stackoverflow.com/questions/12916422/assertion-failure-in-uiqueuingscrollview-didscrollwithanimationforce

Can u help me check if the problem is really from DYMRollingBanner or not. Thanks.

TODO List:

  1. Disable scrolling when there is only one image.
  2. Provide option to the caller to enable/disable infinite scrolling
  3. Hide the page control when there is only one image.

Transparent background request

Is there a way this could be made so that if AspectFit is used, any areas of the view that don't take up the UIImageView are transparent, showing the background of the app behind it?

Cant release ChildviewController

MyChildController * child;
__weak MyParentViewController *weakSelf = self;
[child.mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(weakSelf.myView);
}];

when i call child removeFromParentViewController. it wont call dealloc on MyChildController, when i comment this code make contraints. it calls dealloc on MyChildController

The minimum deployment target

I notice that the minimum deployment target is set to iOS 8.0, is there any iOS 8.0 api called?

s.platform = :ios, '8.0'

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.