coverFlow 사진 클릭 이벤트

3334 단어 overflow
ViewController.h

//
//  ViewController.h
//  overFlow010
//
//  Created by Bo Xiu on 12-9-15.
//  Copyright (c) 2012  Bo Xiu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AFOpenFlowView.h"

@interface ViewController : UIViewController<AFOpenFlowViewDataSource, AFOpenFlowViewDelegate> {
    
    //         .
    
    NSArray *coverImageData;
    AFOpenFlowView *flowView;
}

//          .
@property (nonatomic,retain)  AFOpenFlowView *flowView;
- (void) imageDidLoad:(NSArray *)arguments;
- (void)openFlowView:(AFOpenFlowView *)openFlowView selectionDidChange:(int)index;
//longquan begin
- (void)openFlowView:(AFOpenFlowView *)openFlowView singleTaped:(int)index;
//longquan end
@end

ViewController.m

//
//  ViewController.m
//  overFlow010
//
//  Created by Bo Xiu on 12-9-15.
//  Copyright (c) 2012  Bo Xiu. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize flowView;
- (void)viewDidLoad
{
    [super viewDidLoad];
     //((AFOpenFlowView *)self.view).viewDelegate = self;
    flowView = [[AFOpenFlowView alloc]initWithFrame:CGRectMake(0, 0, 320, 640)];
    //[self.view setDelegate:self];
    flowView.viewDelegate = self;
    coverImageData = [NSArray arrayWithObjects:[UIImage imageNamed:@"0.jpg"],  
					  [UIImage imageNamed:@"1.jpg"],
					  [UIImage imageNamed:@"2.jpg"],
					  [UIImage imageNamed:@"3.jpg"],              
					  [UIImage imageNamed:@"4.jpg"],              
					  [UIImage imageNamed:@"5.jpg"],          
					  [UIImage imageNamed:@"6.jpg"],    
					  nil];
    
	// Set the Images in OpenFlow View and set the count of images.
    
	for (int i=0; i < [coverImageData count]; i++) {
        
		[flowView setImage:[coverImageData objectAtIndex:i] forIndex:i];
        
	}
    
	[flowView setNumberOfImages:[coverImageData count]];
    [self.view addSubview:flowView];
}
- (void)openFlowView:(AFOpenFlowView *)openFlowView selectionDidChange:(int)index{
    NSLog(@"%d is selected",index);
    NSLog(@"ViewController.selectionDidChange");
}
- (void)openFlowView:(AFOpenFlowView *)openFlowView singleTaped:(int)index{
    NSLog(@"%d is selected",index);
    NSLog(@"ViewController.singleTaped");
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

@end


좋은 웹페이지 즐겨찾기