UI 运用滚动视图创建相册的方法
来源:互联网 发布:sql 事务回滚 编辑:程序博客网 时间:2024/06/05 07:59
UI 运用滚动视图创建相册的方法:
#import "mainViewController.h"
@interface mainViewController ()
@end
@implementation mainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//总的
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(20, 20, 280, 450)];
scrollView.backgroundColor = [UIColor redColor];
scrollView.tag = 1000;
scrollView.contentSize = CGSizeMake(1400, 0);
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = YES;
//第一个
UIScrollView *scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(20, 20, 240, 450)];
scrollView1.contentSize = CGSizeMake(240, 0);
scrollView1.tag = 111;
UIImageView *image0 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 240, 400)];
image0.image = [UIImage imageNamed:@"1.JPG"];
[scrollView1 addSubview:image0];
[image0 release];
scrollView1.delegate = self;
scrollView1.minimumZoomScale = 0.5;
scrollView1.maximumZoomScale = 2;
[scrollView addSubview:scrollView1];
[scrollView1 release];
//第二个
UIScrollView *scrollView2 = [[UIScrollView alloc] initWithFrame:CGRectMake(300, 20, 240, 450)];
scrollView2.contentSize = CGSizeMake(280, 0);
scrollView2.tag = 222;
UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 240, 400)];
image1.image = [UIImage imageNamed:@"2.JPG"];
[scrollView2 addSubview:image1];
[image1 release];
scrollView2.delegate = self;
scrollView2.minimumZoomScale = 0.5;
scrollView2.maximumZoomScale = 2;
[scrollView addSubview:scrollView2];
[scrollView2 release];
//第三个
UIScrollView *scrollView3 = [[UIScrollView alloc] initWithFrame:CGRectMake(580, 20, 240, 450)];
scrollView3.contentSize = CGSizeMake(280, 0);
scrollView3.tag = 333;
UIImageView *image2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 240, 400)];
image2.image = [UIImage imageNamed:@"3.JPG"];
[scrollView3 addSubview:image2];
[image2 release];
scrollView3.delegate = self;
scrollView3.minimumZoomScale = 0.5;
scrollView3.maximumZoomScale = 2;
[scrollView addSubview:scrollView3];
[scrollView3 release];
//第四个
UIScrollView *scrollView4 = [[UIScrollView alloc] initWithFrame:CGRectMake(860, 20, 240, 450)];
scrollView4.contentSize = CGSizeMake(280, 0);
scrollView4.tag = 444;
UIImageView *image3 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 240, 400)];
image3.image = [UIImage imageNamed:@"4.JPG"];
[scrollView4 addSubview:image3];
[image3 release];
scrollView4.delegate = self;
scrollView4.minimumZoomScale = 0.5;
scrollView4.maximumZoomScale = 2;
[scrollView addSubview:scrollView4];
[scrollView4 release];
//第五个
UIScrollView *scrollView5 = [[UIScrollView alloc] initWithFrame:CGRectMake(1140, 20, 240, 450)];
scrollView5.contentSize = CGSizeMake(280, 0);
scrollView5.tag = 555;
UIImageView *image4 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 240, 400)];
image4.image = [UIImage imageNamed:@"5.JPG"];
[scrollView5 addSubview:image4];
[image4 release];
scrollView5.delegate = self;
scrollView5.minimumZoomScale = 0.5;
scrollView5.maximumZoomScale = 2;
[scrollView addSubview:scrollView5];
[scrollView5 release];
scrollView.delegate = self;
[self.view addSubview:scrollView];
[scrollView release];
UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(110, 400, 100,30)];
pageControl.numberOfPages = 5;
pageControl.pageIndicatorTintColor = [UIColor blackColor];
pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
[pageControl addTarget:self action:@selector(pageControlAction:)forControlEvents:UIControlEventValueChanged];
[self.view addSubview:pageControl];
[pageControl release];
self.page = pageControl;
}
- (void)pageControlAction:(UIPageControl *)pageControl
{
UIScrollView *scrollView = (UIScrollView *) [self.view viewWithTag:1000];
scrollView.contentOffset = CGPointMake(280 * self.page.currentPage, 0);
for (int i = 1; i < 6; i++) {
UIScrollView *scrollView = (UIScrollView *) [self.view viewWithTag:111 * i];
scrollView.zoomScale = 1;
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
self.page.currentPage = scrollView.contentOffset.x / scrollView.frame.size.width;
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return [scrollView.subviews firstObject];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
for (int i = 1; i < 6; i ++) {
UIScrollView *scrollView = (UIScrollView *) [self.view viewWithTag:111 * i];
scrollView.zoomScale = 1;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
- UI 运用滚动视图创建相册的方法
- UI-滚动视图(滚动视图)
- 滚动视图UIScrollView设置滚动的方法
- UI滚动视图
- UI:UIScrollView滚动视图
- UI 界面设计 滚动视图
- UI笔记_UIScrollView滚动视图
- UI UIScrollView所有滚动视图的基类
- 进击的KFC:UI(七)滚动视图 和 分页按钮
- scrollView中视图滚动调用的方法
- 改变滚动视图的方法实现
- UI创建霓虹灯视图
- UI设计 创建视图
- ORACLE视图的创建方法
- IOS开发系列之UIScrollView(滚动视图)的常用属性和应用举例(滑动相册、轮播图)
- UIScrollView的循环滚动相册
- UI06_无限滚动的相册
- UI(手势综合运用)代码实现简单相册
- 会话技术
- iOS 简单总结:description方法/NSLog函数
- web.xml里<filter-mapping>中的<dispatcher>作用
- android中跨进程通讯的4种方式
- iOS-利用AFNetworking(AFN 1.x)-实现文件上传
- UI 运用滚动视图创建相册的方法
- 滚动条的监听 与内容随着滚动条动态加载
- struts2.2.1关于sitemesh和freemarker整合的细节
- Oracle 安装报错 [INS-06101] IP address of localhost could not be determined 解决方法
- Swift编程语言入门视频教程(九)--基本算术运算符
- C#委托的使用
- 用SPFA的最小费用流算法
- Swift编程语言入门视频教程(十)--逻辑条件赋值运算符
- opengl es 纹理无法显示的问题