记录一下学习进度,本人是哥菜鸟,有什么翻译不对的地方请大家指出来。
// UIScrollView.h
// UIKit
//
// Copyright (c) 2007-2014 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIView.h>
#import <UIKit/UIGeometry.h>
#import <UIKit/UIKitDefines.h>
// UIKit
//
// Copyright (c) 2007-2014 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIView.h>
#import <UIKit/UIGeometry.h>
#import <UIKit/UIKitDefines.h>
typedef
NS_ENUM
(NSInteger, UIScrollViewIndicatorStyle) {
UIScrollViewIndicatorStyleDefault,
//
默认灰色的
UIScrollViewIndicatorStyleBlack,
//黑色的滚动条样式
UIScrollViewIndicatorStyleWhite
//白色的滚动条样式
typedef
NS_ENUM
(NSInteger, UIScrollViewKeyboardDismissMode) {
UIScrollViewKeyboardDismissModeNone,
//默认的,键盘不会隐藏
UIScrollViewKeyboardDismissModeOnDrag,
//拖拽scrollView时隐藏键盘
UIScrollViewKeyboardDismissModeInteractive,
//你的手指一直在拖拽时,键盘会随着你的手指拖拽的方向,向上或者向下
} NS_ENUM_AVAILABLE_IOS(
7
_0);
//默认减速率
UIKIT_EXTERN
const
CGFloat UIScrollViewDecelerationRateNormal NS_AVAILABLE_IOS(
3
_0);
UIKIT_EXTERN
const
CGFloat UIScrollViewDecelerationRateFast NS_AVAILABLE_IOS(
3
_0);
@class
UIEvent, UIImageView, UIPanGestureRecognizer, UIPinchGestureRecognizer;
@protocol UIScrollViewDelegate;
NS_CLASS_AVAILABLE_IOS( 2 _0) @interface UIScrollView : UIView <NSCoding> {
@package
id _delegate;
@protocol UIScrollViewDelegate;
NS_CLASS_AVAILABLE_IOS( 2 _0) @interface UIScrollView : UIView <NSCoding> {
@package
id _delegate;
}
=========================UIScrollView的属性和方法=========================
@property
(
nonatomic
) CGPoint contentOffset;
// default CGPointZero
@property
(
nonatomic
) CGSize contentSize;
// default CGSizeZero
可滚动的区域
@property
(
nonatomic
) UIEdgeInsets contentInset;
// 在原来的滚动区域额外加上另外可滚动的区域
@property
(
nonatomic
,
assign
)
id
<UIScrollViewDelegate> delegate;
// 设置协议
@property
(
nonatomic
,
getter
=isDirectionalLockEnabled)
BOOL
directionalLockEnabled;
// 默认是NO,指定控件是否只能在一个方向上滚动
@property
(
nonatomic
)
BOOL
bounces;
// 控件是否有弹簧效果
@property
(
nonatomic
)
BOOL
alwaysBounceVertical;
// 控件垂直方向上是否有弹簧效果,默认是NO
@property
(
nonatomic
)
BOOL
alwaysBounceHorizontal;
// 控件水平方向上是否有弹簧效果,默认是NO
@property
(
nonatomic
,
getter
=isPagingEnabled)
BOOL
pagingEnabled;
//是否整页翻动
@property
(
nonatomic
,
getter
=isScrollEnabled)
BOOL
scrollEnabled;
//
是否能滚动
@property
(
nonatomic
)
BOOL
showsHorizontalScrollIndicator;
//
是否显示水平方向的滚动条
@property
(
nonatomic
)
BOOL
showsVerticalScrollIndicator;
//
是否显示垂直方向的滚动条
@property
(
nonatomic
) UIEdgeInsets scrollIndicatorInsets;
// 滚动条在scrollerView中的扩展位置
@property
(
nonatomic
) UIScrollViewIndicatorStyle indicatorStyle;
// default is UIScrollViewIndicatorStyleDefault 设置滚动条的样式
UIScrollViewIndicatorStyleDefault 默认灰色的
UIScrollViewIndicatorStyleBlack 黑色
UIScrollViewIndicatorStyleWhite 白色
@property
(
nonatomic
) CGFloat decelerationRate NS_AVAILABLE_IOS(
3
_0);
手指放开滚动后的减速率
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; // 设置滚动到某个点时 是否有动画
- (
void
)scrollRectToVisible:(CGRect)rect animated:(
BOOL
)animated;
// 滚动到指定的区域 是否要动画
- ( void )flashScrollIndicators; // displays the scroll indicators for a short time. This should be done whenever you bring the scroll view to front.
/*
*/
UIScrollView的事件响应顺序跟一般的不同, UIScrollView 的工作原理,当手指 touch 的时候, UIScrollView 会拦截 Event, 会等待一段时间,在这段时间内,如果没有手指没有移动,当时间结束时, UIScrollView 会发送 tracking events 到子视图上。在时间结束前,手指发生了移动,那么 UIScrollView 就会进行移动,从而取笑发送 tracking 顺序说明: 当手指 touch 的时候,如果 scrollView 上面有可交互的视图, track, ->或滑动或点击
@property
(
nonatomic
,
readonly
,
getter
=isTracking)
BOOL
tracking;
//用户是否按上了,不管滑动没滑动
@property
(
nonatomic
,
readonly
,
getter
=isDragging)
BOOL
dragging;
//用户手指在scroll时,松开了就为NO了
@property
(
nonatomic
,
readonly
,
getter
=isDecelerating)
BOOL
decelerating;
// returns YES if user isn't dragging (touch up) but scroll view is still moving
@property
(
nonatomic
)
BOOL
delaysContentTouches;
//手指点到类的时候,如果它为yes,则按之前讲的处理,如果为NO,并且点在了“可交互的视图”,立马调用
-touchesShouldBegin:withEvent:inContentView:
@property
(
nonatomic
)
BOOL
canCancelContentTouches;
//
- (
BOOL
)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view;
//对上面几个属性做一次总体的总结
//从你的手指touch屏幕开始,scrollView开始一个timer,如果:
//1.150ms内如果你的手指没有任何动作,消息就会传给subView.
//2.150ms内手指有明显的滑动,scrollView就会滚动,消息不会传给subView。
//3.150ms内手指没有滑动,scrollView将消息传给subView,但是之后手指开始滑动,scrollView发送
touchesShouldCancelInContentView消息给subView,(如果canCancelContentTouches为NO,各个消息已经传递给subView了,scroll事件就不会再发生)然后开始滚动。
//如tableView的情况,先按住一个cell,cell开始高亮,手不放开,开始滑动,tableView开始滚动,cell高亮就取消了。
//delaysContentTouches作用:默认是YES,使用上面的150ms的timer,如果设置为NO,touch事件立即传递给subView,不会有150ms的等待了。
- (
BOOL
)touchesShouldCancelInContentView:(UIView *)view;
=========================缩放相关=============================
//缩放的最小比例 默认1.0
@property
(
nonatomic
) CGFloat minimumZoomScale;
//缩放的最大比例 默认1.0
@property
(
nonatomic
) CGFloat maximumZoomScale;
//缩放的比例(值在minimumZoomScale和maximumZoomScale之间变化)
default is 1.0
@property
(
nonatomic
) CGFloat zoomScale NS_AVAILABLE_IOS(
3
_0);
//
- (
void
)setZoomScale:(CGFloat)scale animated:(
BOOL
)animated NS_AVAILABLE_IOS(
3
_0);
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated NS_AVAILABLE_IOS(3_0);
//控制缩放到边界时是否会反弹 默认是YES
@property
(
nonatomic
)
BOOL
bouncesZoom;
//判断控件的大小是否正在缩放
@property
(
nonatomic
,
readonly
,
getter
=isZooming)
BOOL
zooming;
//判断控件是否缩放到了 最大/最小
@property
(
nonatomic
,
readonly
,
getter
=isZoomBouncing)
BOOL
zoomBouncing;
//设置单击状态栏是否回滚到顶部
@property
(
nonatomic
)
BOOL
scrollsToTop;
// default is YES.
//拖拽手势 只读属性
@property
(
nonatomic
,
readonly
) UIPanGestureRecognizer *panGestureRecognizer NS_AVAILABLE_IOS(
5
_0);
//
缩放,移动,旋转手势 只读属性
@property
(
nonatomic
,
readonly
) UIPinchGestureRecognizer *pinchGestureRecognizer NS_AVAILABLE_IOS(
5
_0);
@property ( nonatomic ) UIScrollViewKeyboardDismissMode keyboardDismissMode NS_AVAILABLE_IOS( 7 _0); // default is UIScrollViewKeyboardDismissModeNone
@property ( nonatomic ) UIScrollViewKeyboardDismissMode keyboardDismissMode NS_AVAILABLE_IOS( 7 _0); // default is UIScrollViewKeyboardDismissModeNone
@end
=====================UIScrollViewDelegate=========================
@protocol
UIScrollViewDelegate<NSObject>
@optional 不是必须完成的代理方法
// 当
offset改变时 调用
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
//当缩放时调用
- (
void
)scrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(
3
_2);
//
当手指在scrollView上拖拽时调用一次
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
// 拖拽将要结束时调用
velocity(速率)=
points/millisecond
targetContentOffset(
CGPoint * 类型
)
滑动停止时的点
inout:正式协议里的关键字,参数既是输入参数,又是输出参数。
- (
void
)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(
inout
CGPoint *)targetContentOffset NS_AVAILABLE_IOS(
5
_0);
// 拖拽结束时
- (
void
)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(
BOOL
)decelerate;
//手指停止拖拽,
将要开始减速时调用
- (
void
)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
//不再滚动时调用
- (
void
)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
//当
setContentOffset/scrollRectVisible:animated:完成时调用,如果没有动画则不会被调用
- (
void
)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
//返回一个将要被缩放的View
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
//将要开始缩放时调用
- (
void
)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view NS_AVAILABLE_IOS(
3
_2);
//缩放结束时调用,scale是你设置的min
imumZoomScale和
maximumZoomScale之间的值
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale;
//
点击状态栏是否滚动到顶部 默认是 return YES
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;
//点击状态栏滚动到顶部时调用,如果已经在顶部点击状态栏也不会调用
- (
void
)scrollViewDidScrollToTop:(UIScrollView *)scrollView;
@end