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的更多相关文章
随机推荐
- Android 手机设置CMWAP 接入点
Android 手机设置CMWAP 接入点 设置--- 无限控件---移动网络设置---接入点名称----再按菜单---选择新apn 第一步,设置CMNET 上网APN 新建 APN 1.名称:cmn ...
- 怎样利用App打造自明星实现自盈利
怎样利用App打造自明星实现自盈利 1.了解各个概念 为了大家都能看懂这篇文章,先说明几个概念. App(Application):能够在移动设备上使用,满足人们咨询.购物. ...
- 【JavaScript】使用面向对象的技术创建高级 Web 应用程序
本文讨论: JavaScript 是基于原型的语言 用 JavaScript 进行面向对象的编程 JavaScript 编码技巧 JavaScript 的未来 本文使用了以下技术: JavaScrip ...
- [Express] Level 3: Reading from the URL
City Search We want to create an endpoint that we can use to filter cities. Follow the tasks below t ...
- ChinaASP.Upload 错误 '80040002' You must add our copyright info
ChinaASP.Upload 错误 '80040002' You must add our copyright info: http://www.chinaasp.com 修改 第一步:在“开始-运 ...
- 0c-40-ARC下多对象内存管理
1个人拥有1条狗. 问题1:人拥有狗作为成员变量,此时使用weak,释放过程是什么样? Person *p = [Person new]; Dog *d = [Dog new]; //设置人拥有dog ...
- LINUX CACHE IO THREAD
http://www.penglixun.com/tech/system/linux_cache_discovery.html http://my.oschina.net/HardySimpson/b ...
- 实例讲解Linux系统中硬链接与软链接的创建
导读 Linux链接分两种,一种被称为硬链接(Hard Link),另一种被称为符号链接(Symbolic Link).默认情况下,ln命令产生硬链接.硬链接与软链接的区别从根本上要从Inode节点说 ...
- Preventing CSRF in Java web apps---reference
reference from:http://ricardozuasti.com/2012/preventing-csrf-in-java-web-apps/ Cross-site request fo ...
- 重置kafka的offset
如果你在使用Kafka来分发消息,在数据处理的过程中可能会出现处理程序出异常或者是其它的错误,会造成数据丢失或不一致.这个时候你也许会想要通过kafka把数据从新处理一遍,我们知道kafka默认会在磁 ...