coverFlow 图片点击事件

本文介绍了一个用于iOS应用中的图片展示视图控制器实现。该视图控制器利用AFOpenFlowView组件展示一系列图片,并实现了数据源及代理方法来响应图片选择及单击事件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值