- 浏览: 2478419 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jsntghf:
peio 写道这个怎么运行?Ruby On Rails的环境搭 ...
多文件上传之uploadify -
peio:
这个怎么运行?
多文件上传之uploadify -
往事如烟1:
我的项目是自己init了一个原始的project,之后将ver ...
React Native热部署之CodePush -
jsntghf:
往事如烟1 写道我按照你的说明进行,发现app退出之后,在进入 ...
React Native热部署之CodePush -
往事如烟1:
我按照你的说明进行,发现app退出之后,在进入不正确,请问是什 ...
React Native热部署之CodePush
MyScrollView.h
#import <UIKit/UIKit.h> @interface MyScrollView : UIScrollView <UIScrollViewDelegate> { UIImage *image; UIImageView *imageView; } @property (nonatomic, retain) UIImage *image; @end
MyScrollView.m
#import "MyScrollView.h" @implementation MyScrollView @synthesize image; - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { self.delegate = self; self.minimumZoomScale = 0.5; self.maximumZoomScale = 2.5; self.showsVerticalScrollIndicator = NO; self.showsHorizontalScrollIndicator = NO; imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; imageView.contentMode = UIViewContentModeCenter; [self addSubview:imageView]; } return self; } - (void)setImage:(UIImage *)img { imageView.image = img; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return imageView; } - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { CGFloat zs = scrollView.zoomScale; zs = MAX(zs, 1.0); zs = MIN(zs, 2.0); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; scrollView.zoomScale = zs; [UIView commitAnimations]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch tapCount] == 2) { CGFloat zs = self.zoomScale; zs = (zs == 1.0) ? 2.0 : 1.0; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; self.zoomScale = zs; [UIView commitAnimations]; } } - (void)dealloc { [image release]; [imageView release]; [super dealloc]; } @end
MainViewController.h
#import "MyScrollView.h" @interface MainViewController : UIViewController <UIScrollViewDelegate> { IBOutlet UIScrollView *scrView; NSInteger lastPage; } @end
MainViewController.m
#import "MainViewController.h" @implementation MainViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor blackColor]; scrView.contentSize = CGSizeMake(1700, 480); scrView.showsHorizontalScrollIndicator = NO; for (int i = 0; i < 5; i++) { MyScrollView *ascrView = [[MyScrollView alloc] initWithFrame:CGRectMake(340 * i, 0, 320, 480)]; NSString *imgPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d", i + 1] ofType:@"jpg"]; ascrView.image = [UIImage imageWithContentsOfFile:imgPath]; ascrView.tag = 100 + i; [scrView addSubview:ascrView]; [ascrView release]; } lastPage = 0; } //划动的动画结束后调用 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGFloat pageWidth = scrollView.frame.size.width; NSInteger page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; if (lastPage != page) { MyScrollView *aView = (MyScrollView *)[scrView viewWithTag:100 + lastPage]; aView.zoomScale = 1.0; lastPage = page; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { scrView = nil; } - (void)dealloc { [scrView release]; [super dealloc]; } @end
- PBEx.zip (587.7 KB)
- 下载次数: 234
发表评论
-
Error watching file for changes: EMFILE
2016-12-15 11:57 1240执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 743ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1562React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3794React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2736package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 1951React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1670确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1685Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6134本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4274React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2100本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1396本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3083很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1173NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 646主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16069UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1135GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1180Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1047__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1694self.view.backgroundColor = [U ...
相关推荐
我学习过程中一个简单的滚动视图实例,方便和我一样的初学者学习。 简介:在主视图中添加滚动视图,每次滚动一页,可以通过UIPageControl滑动页面,有详细中文说明。
例子 要运行示例项目,请克隆存储库,然后首先从Example目录运行pod install 。 要求 安装 可通过获得 。 要安装它,只需将以下行添加到您的Podfile中: pod 'HPParallaxHeader' 作者 , 执照 HPParallaxHeader在...
ios pagecontrol例子,iphone6.1测试通过。简单翻页框架,用UIscrollView加载内容页,施行页数控制。具体说明和截图参照:http://blog.csdn.net/donny_zhang
一个很简单的UIScrollView结合UIPageControl的图片翻页的例子
MAPullToRefresh是在 UITableViews、UITableViewControllers 和 UIScrollViews 上实现美观的下拉刷新功能的最简单方法。 UIScrollview 的分类和实现,只需几行代码。 它开箱即用! 要求 MAPullToRefresh使用 ARC ...
编辑器中能设计静态展示的UIScrollView,而通常我们都需要在程序中动态...在3.0中UILayout已经实现了基本的布局,这个例子则是一个简单的实现。相关博客地址:http://blog.csdn.net/fansongy/article/details/17382049
刷新器很简单,如UIRefreshControl。 不需要添加UIScrollView委托。 要求 斯威夫特5 iOS 8.0或更高版本 tvOS 9.0或更高版本 如何安装SpringIndicator 椰子足 将以下内容添加到您的Podfile : pod ...
MJ刷新 使用拉动刷新的简单方法 内容入门 评论API 例子支持刷新哪些控件UIScrollView , UITableView , UICollectionView , WKWebView如何使用MJRefresh 使用CocoaPods进行安装: pod 'MJRefresh' 用安装: github...
一个简单的代理类,它多路复用和分派协议方法到多个对象。 安装 AOMultiproxier 可通过。 要安装它,只需将以下行添加到您的 Podfile 中: pod "AOMultiproxier" 例子 在您的标题中: @property (nonatomic, ...