GithubHelp home page GithubHelp logo

bluelich / cxphotobrowser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisxu/cxphotobrowser

0.0 3.0 0.0 535 KB

Photo browser for iOS, Inspiring by @MWPhotoBrowser. Supporting with high level customization, including Navigationbar, Toolbar, Loading process placeholder and Loading failure placeholder.

License: MIT License

Ruby 1.16% Objective-C 98.84%

cxphotobrowser's Introduction

#CXPhotoBrowser - Customize your photobrowser for iOS.

A photo browser Inspiring by @MWPhotoBrowser. Removing the dependcy with other library, so you can choose your favorite Async library to download image online. Supporting with high level of customization, including Navigationbar, Toolbar, Loading process placeholder and Loading failure placeholder. You can build a photo browser similar to facebook.


ScreenShot 1, ScreenShot 2,


##Installation (v1.1.1)

  • CocoaPods add pod 'CXPhotoBrowser'

usage like @MWPhotoBrowser

###How to use

*Create a photobrowser(CXPhotoBrowser).

photobrowser = [[CXPhotoBrowser alloc] initWithDataSource:self delegate:self];

*Remember to set the datasource and delegate.

CXPhoto *photo = [[CXPhoto alloc] initWithURL:<#(NSURL)#>];
[self.photoDataSource addObject:photo];

Add the view to your current view.

[photobrowser setInitialPageIndex:indexPath.row];
[self.view addSubview:photobrowser.view];

~~*You should create your own Photo class by inherit from CXPhoto. And implement 'loadImageFromURLAsync:' for downloading images.~~Support in v1.1.1.

*Sample

- (void)loadImageFromURLAsync:(NSURL *)url
{
    [self notifyImageDidStartLoad];
    SDWebImageManager *manager = [SDWebImageManager sharedManager];
    [manager downloadWithURL:url options:0 progress:^(NSUInteger receivedSize, long long expectedSize)
    {
        [_photoLoadingView loadWithReceivedSize:receivedSize expectedSize:expectedSize];
    } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
        if (!error)
        {
            _underlyingImage = image;
            
            [self notifyImageDidFinishLoad];
        }
        else
        {
            [self notifyImageDidFailLoadWithError:error];
        }
    }];
}

###Data Source *Required methods(2):

- (NSUInteger)numberOfPhotosInPhotoBrowser:(CXPhotoBrowser *)photoBrowser
{
    return [self.photoDataSource count];
}

- (id <CXPhotoProtocol>)photoBrowser:(CXPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
{
    if (index < self.photoDataSource.count)
        return [self.photoDataSource objectAtIndex:index];
    return nil;
}

*Optional methods(Customize UI):

- (CXBrowserNavBarView *)browserNavigationBarViewOfOfPhotoBrowser:(CXPhotoBrowser *)photoBrowser withSize:(CGSize)size;
- (CXBrowserToolBarView *)browserToolBarViewOfPhotoBrowser:(CXPhotoBrowser *)photoBrowser withSize:(CGSize)size;

###Delegate

- (void)photoBrowser:(CXPhotoBrowser *)photoBrowser didChangedToPageAtIndex:(NSUInteger)index;
- (void)photoBrowser:(CXPhotoBrowser *)photoBrowser didFinishLoadingWithCurrentImage:(UIImage *)currentImage;
- (BOOL)supportReload;

###What's new in this version (v1.1.1)

  • support default CXPhoto to use.
  • NSLocalizedString
  • Photo Reload Action.(Declare in CXPhoto)

###Next (v1.2.0)

  • Handle orientation chagne.
  • Support more gesture.
  • Support Facebook's album style.

###Supports

  • iOS 4 or later.
  • Xcode 4.2 (CXPhotoBrowser uses ARC)
  • Required frameworks: Foundation, UIKit, CoreGraphics and ImageIO.

##Contact Follow @taterctl

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

##License

Copyright (c) 2013 Chris Xu, Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)

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.

cxphotobrowser's People

Contributors

chrisxu avatar paulmars avatar

Watchers

 avatar  avatar  avatar

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.