GithubHelp home page GithubHelp logo

nhslideshow's Introduction

NHSlideShow

This control provides varity of animation options to run a slideshow on iphone, ipod and ipad as well. It maintains a circular queue of images.

This control is also available on Cocoacontrols.com: https://www.cocoacontrols.com/controls/nhslideshow

Here is how it looks like:

Runtime View

The attached source code is available for both storyboard and XIBs. On slight modification in code can change the mode from storyboard to XIBs.

How to integrate:

- (void)viewDidLoad
{
     [super viewDidLoad];

      // Create slide show control
      slideShow = [[NHSlideShow alloc] initWithFrame:CGRectMake(0, 0, kScreenSize.height, kScreenSize.width)]; 
     [slideShow setDelayInTransition:2.0f];
     [slideShow setDelegate:self];
     [slideShow slidesWithImages:[self getImages]];
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
     // This will help to run the same code on iphone if single layout files 
     // designed for both iphone 4 and iphone 5.
    [slideShow doneLayout];
    
     // Start slide show
    [slideShow start];
}

#pragma mark - Helper functions

-(NSArray *)getImages
{
    // Create array of images to be run in slide show
     NSMutableArray *mArr = [[NSMutableArray alloc] init];
    
    [mArr addObject:[UIImage imageNamed:@"1.png"]];
    [mArr addObject:[UIImage imageNamed:@"2.png"]];
    [mArr addObject:[UIImage imageNamed:@"3.png"]];
    
    [mArr addObject:[UIImage imageNamed:@"4.png"]];
    [mArr addObject:[UIImage imageNamed:@"5.png"]];
    [mArr addObject:[UIImage imageNamed:@"6.png"]];
    
    [mArr addObject:[UIImage imageNamed:@"7.png"]];
    [mArr addObject:[UIImage imageNamed:@"8.png"]];
    [mArr addObject:[UIImage imageNamed:@"9.png"]];
    
    [mArr addObject:[UIImage imageNamed:@"10.png"]];    
    
     return mArr;
}

#pragma mark - Event Handlers

-(IBAction)valueChanged:(UISegmentedControl *)segmentedControl
{
    // Change animation mode
    NSLog(@"ValueChanged...");
    
    switch (segmentedControl.selectedSegmentIndex)
    {
        case NHSlideShowModeSwipeLeft:
        {
            [slideShow setSlideShowMode:NHSlideShowModeSwipeLeft];
        }break;
        case NHSlideShowModeFade:
        {
            [slideShow setSlideShowMode:NHSlideShowModeFade];
        }break;
        case NHSlideShowModeScale:
        {
            [slideShow setSlideShowMode:NHSlideShowModeScale];
        }break;
        case NHSlideShowModeWindow:
        {
            [slideShow setSlideShowMode:NHSlideShowModeWindow];
        }break;
        case NHSlideShowModeRandom:
        {
            [slideShow setSlideShowMode:NHSlideShowModeRandom];
        }break;
        default:
            break;
    }  
}

-(IBAction)modeValueChanged:(UISegmentedControl *)segmentedControl
{
    // Change slide execution mode
    NSLog(@"ValueChanged...");
    
    switch (segmentedControl.selectedSegmentIndex)
    {
        case 0:
        {
            [slideShow start];
        }break;
        case 1:
        {
            [slideShow stop];
        }break;
        default:
            break;
    }
}

-(IBAction)btnNext_Click:(id)sender
{
     // Move to next slide
    [slideShow moveNext];
}

-(IBAction)btnPrevious_Click:(id)sender
{
     // Move to previous slide
    [slideShow movePrevious];
}

#pragma mark - NHSlideShow delegate functions


-(NSInteger)slideShowShouldStartFromSlide:(NHSlideShow *)slideShow
{
    return 0; // Return your starting slide number
}

-(void)slideShow:(NHSlideShow *)slideShow didChangedSlideAtIndex:(NSInteger)slideIndex
{
    // TODO: You can display your image description using this delegate.
    NSLog(@"didChangedSlideAtIndex : %ld", (long)slideIndex);
}

nhslideshow's People

Contributors

neverhopeless avatar

Watchers

James Cloos avatar Utsav Dusad 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.