UI1_UIScrollView
//
// AppDelegate.m
// UI1_UIScrollView
//
// Created by zhangxueming on 15/7/10.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "AppDelegate.h"
#import "ViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
ViewController *root = [[ViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:root];
self.window.rootViewController = nav;
self.window.backgroundColor = [UIColor whiteColor]; return YES;
}
//
// ViewController.h
// UI1_UIScrollView
//
// Created by zhangxueming on 15/7/10.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIScrollViewDelegate> @end
//
// ViewController.m
// UI1_UIScrollView
//
// Created by zhangxueming on 15/7/10.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *path = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
imageView.image = image;
//[self.view addSubview:imageView];
//创建滚动视图
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
//设置内容视图的大小
//跟imageView的大小相同
scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
[scrollView addSubview:imageView];
scrollView.backgroundColor = [UIColor redColor];
//消除导航栏的影响,显示的视图不被导航栏覆盖
self.automaticallyAdjustsScrollViewInsets = NO; //隐藏滚动条
//横向的指示条
scrollView.showsHorizontalScrollIndicator = NO;
//竖向的指示条
scrollView.showsVerticalScrollIndicator = YES; //设置边界回弹
scrollView.bounces = YES;
//滚动视图的偏移, 相对于内容视图的偏移
scrollView.contentOffset = CGPointMake(0, 0);
//设置分页
//必然有一个减速的过程
scrollView.pagingEnabled = YES;
//是否滚动
scrollView.scrollEnabled = YES; //[scrollView setContentOffset:CGPointMake(-100, -100) animated:YES];
//[scrollView flashScrollIndicators]; //设置放大缩小的系数
scrollView.delegate = self;
scrollView.minimumZoomScale = 0.2;
scrollView.maximumZoomScale = 3; [self.view addSubview:scrollView];
} #pragma mark --UIScrollViewDelegate---
//视图发生滚动时调用
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//NSLog(@"----滚动----");
}
//视图发生拖拽的时候调用
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
NSLog(@"----拉拽----");
} //拖拽结束时调用
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
NSLog(@"decelerate = %i", decelerate);
if (decelerate) {
NSLog(@"拖拽减速");
}
}
//返回要放大子视图
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
NSLog(@"图片被放大"); return [scrollView.subviews objectAtIndex:0];
} //当有减速过程的时候才被调用
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
NSLog(@"开始减速");
}
//如果设置分页使能, 那么该方法肯定被调用
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"减速结束");
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
UI1_UIScrollView的更多相关文章
随机推荐
- Docker:使用Ambassador进行跨主机间容器通信
转载请注明出处:点我 由于Docker自身的网络的原因,想要在多主机间的容器之间进行通信是比较麻烦的事情.可以利用Ambassador容器来实现这一功能. 基本原理: 利用Ambassador来实现主 ...
- Mac OS X下高速拷贝文件路径
文件路径表示的是文件在文件系统里的位置,无论是用命令行操作的Linux程序猿还是使用windows的广大用户.都难免会有这种需求 在windows上复制当前文件夹的路径有一个特别方便的方式,仅仅须要用 ...
- C++基础之预处理命令
目录 概述——对预处理命令的理解 预处理命令的处理时间 C++中主要的预处理命令 宏定义 “文件包含”处理 选择编译 概述 使用C++的预处理命令可以提高程序的可维护性,有利于程序员以更加方便和快捷的 ...
- DB2 重新设定表自增字段的当前值
转自:http://blog.csdn.net/jionghan3855/article/details/2709073 1.ALTER TABLE UKEY_INFO_TAB ALTER COLUM ...
- 如何快速掌握CSS(各种CSS工具)
CSS中的大量属性难以记忆,通过组合多种CSS工具,可以快速学习常见样式,并提高设计效率.这里给大家推荐一些比较好的在线工具,通过所见即所得图形化界面设计样式,直接得到对应的CSS代码.相比臃肿的集成 ...
- android genymation eclipse安装
http://www.cnblogs.com/1114250779boke/p/3657996.html
- linux 下 奇怪的 动态库 依赖问题
转:http://fanwei51880.blog.163.com/blog/static/3240674020111145285375/ 总结如下:1)当你在编译生成静态库的时候, 只需要相应的依赖 ...
- 功能分解——Android下画分时图与k线图有感
最近工作极度繁忙,已经好久没有更新博客了,总感觉要是再不抽空总结总结点东西,分分钟就会被懒惰的状态给打到了.同时也希望同学们谨记,如果你已经决定要坚持某些正确的东西,比如背完某章单词,看一完本书抑或是 ...
- 关于解决 Failed to prepare partial IU:
在新版本的Eclipse(Luna)中安装插件经常会碰到Failed to prepare partial IU的错误,一把都是兼容性的问题,要下载个兼容包,步骤如下: 1.打开安装插件的页面:Hel ...
- A标签使用javascript:伪协议
一.前言 今天,遇到一个别人挖的坑,问题是这样的. 做了一个列表页,可以筛选数据,有很多筛条件.主要是有input复选框和<a>标签两种.如图: 其中房价的筛选条件使用<a>标 ...