ViewController.h
ViewController.m
//
// 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