iOS 开发 之 - UIScrollView文档

额。这篇文档主银:http://blog.sina.com.cn/u/2141630575 

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIView.h>
#import <UIKit/UIGeometry.h>
#import <UIKit/UIKitDefines.h>

typedef enum {
    UIScrollViewIndicatorStyleDefault,     // black with white border. good against any background
    UIScrollViewIndicatorStyleBlack,       // black only. smaller. good against a white background
    UIScrollViewIndicatorStyleWhite        // white only. smaller. good against a black background
} UIScrollViewIndicatorStyle;

UIKIT_EXTERN const float UIScrollViewDecelerationRateNormal __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
UIKIT_EXTERN const float UIScrollViewDecelerationRateFast __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);

@class UIEvent, UIImageView, UIPanGestureRecognizer, UIPinchGestureRecognizer;
@protocol UIScrollViewDelegate;

UIKIT_CLASS_AVAILABLE(2_0) @interface UIScrollView : UIView <NSCoding> {
  @package
    CGSize       _contentSize;
    UIEdgeInsets _contentInset;
    id           _delegate;
    UIImageView* _verticalScrollIndicator;
    UIImageView* _horizontalScrollIndicator;
    UIEdgeInsets _scrollIndicatorInset;
    struct {
        unsigned int tracking:1;
        unsigned int dragging:1;
        unsigned int verticalBounceEnabled:1;
        unsigned int horizontalBounceEnabled:1;
        unsigned int verticalBouncing:1;
        unsigned int horizontalBouncing:1;
        unsigned int bouncesZoom:1;
        unsigned int zoomBouncing:1;
        unsigned int alwaysBounceHorizontal:1;
        unsigned int alwaysBounceVertical:1;
        unsigned int canCancelContentTouches:1;
        unsigned int delaysContentTouches:1;
        unsigned int programmaticScrollDisabled:1;
        unsigned int scrollDisabled:1;
        unsigned int zoomDisabled:1;
        unsigned int scrollTriggered:1;
        unsigned int scrollDisabledOnTouchBegan:1;
        unsigned int ignoreNextTouchesMoved:1;
        unsigned int cancelNextContentTouchEnded:1;
        unsigned int inContentViewCall:1;
        unsigned int dontSelect:1;
        unsigned int contentTouched:1;
        unsigned int cantCancel:1;
        unsigned int directionalLockEnabled:1;
        unsigned int directionalLockAutoEnabled:1;
        unsigned int lockVertical:1;
        unsigned int lockHorizontal:1;
        unsigned int keepLocked:1;
        unsigned int showsHorizontalScrollIndicator:1;
        unsigned int showsVerticalScrollIndicator:1;
        unsigned int indicatorStyle:2;
        unsigned int inZoom:1;
        unsigned int hideIndicatorsInZoom:1;
        unsigned int pushedTrackingMode:1;
        unsigned int multipleDrag:1;
        unsigned int displayingScrollIndicators:1;
        unsigned int verticalIndicatorShrunk:1;
        unsigned int horizontalIndicatorShrunk:1;
        unsigned int contentFitDisableScrolling:1;
        unsigned int pagingEnabled:1;
        unsigned int pagingLeft:1;
        unsigned int pagingRight:1;
        unsigned int pagingUp:1;
        unsigned int pagingDown:1;
        unsigned int lastHorizontalDirection:1;
        unsigned int lastVerticalDirection:1;
        unsigned int dontScrollToTop:1;
        unsigned int scrollingToTop:1;
        unsigned int useGestureRecognizers:1;
        unsigned int autoscrolling:1;
        unsigned int automaticContentOffsetAdjustmentDisabled:1;
        unsigned int skipStartOffsetAdjustment:1;
        unsigned int delegateScrollViewDidScroll:1;
        unsigned int delegateScrollViewDidZoom:1;
        unsigned int delegateContentSizeForZoomScale:1;
        unsigned int preserveCenterDuringRotation:1;
        unsigned int delaysTrackingWhileDecelerating:1;
        unsigned int pinnedZoomMin:1;
        unsigned int pinnedXMin:1;
        unsigned int pinnedYMin:1;
        unsigned int pinnedXMax:1;
        unsigned int pinnedYMax:1;
        unsigned int skipLinkChecks:1;
        unsigned int staysCenteredDuringPinch:1;
        unsigned int wasDelayingPinchForSystemGestures:1;
        unsigned int systemGesturesRecognitionPossible:1;
        unsigned int disableContentOffsetRounding:1;
        unsigned int adjustedDecelerationTargetX:1;
        unsigned int adjustedDecelerationTargetY:1;
    } _scrollViewFlags;
    CGFloat           _farthestDistance;
    CGPoint           _initialTouchPosition;
    CGPoint           _startTouchPosition;
    CFTimeInterval    _startTouchTime;
    double            _startOffsetX;
    double            _startOffsetY;
    double            _lastUpdateOffsetX;
    double            _lastUpdateOffsetY;
    CGPoint           _lastTouchPosition;
    CFTimeInterval    _lastTouchTime;
    CFTimeInterval    _lastUpdateTime;
    UIView           *_contentView;
    float             _minimumZoomScale;
    float             _maximumZoomScale;
    UIView           *_zoomView;
    double            _horizontalVelocity;
    double            _verticalVelocity;
    double            _previousHorizontalVelocity;
    double            _previousVerticalVelocity;
    CFTypeRef         _scrollHeartbeat;
    CGPoint           _pageDecelerationTarget;
    CGSize            _decelerationFactor;
    CGPoint           _adjustedDecelerationTarget;
    CGSize            _adjustedDecelerationFactor;
    double            _decelerationLnFactorH;
    double            _decelerationLnFactorV;
    NSArray*          _deferredBeginTouchesInfo;
    UIImageView * __strong *_shadows;
    id                _scrollNotificationViews;
    CFTimeInterval    _contentOffsetAnimationDuration;
    id                _animation;
    id                _pinch;
    id                _pan;
    id                _swipe;
    CGFloat           _pagingSpringPull;
    CGFloat           _pagingFriction;
    NSInteger         _fastScrollCount;
    CGFloat           _fastScrollMultiplier;
    CGFloat           _fastScrollStartMultiplier;
    CFTimeInterval    _fastScrollEndTime;
    CGPoint           _parentAdjustment;
    CGPoint           _rotationCenterPoint;
    CGFloat           _accuracy;
    CGFloat           _hysteresis;
    NSUInteger        _zoomAnimationCount;
}

@property(nonatomic)         CGPoint                      contentOffset;
// default CGPointZero。
//在滚轴视图中,contentOffset属性可以跟踪UIScrollView的具体位置,你能够自己获取和设置它,contentOffset的值是你当前可视内容在滚轴视图上面偏移原来的左上角那个点的偏移量,有contentOffset.x和contentOffset.y。

@property(nonatomic)         CGSize                       contentSize;
// default CGSizeZero。
//contentSize是内容的大小,也就是可以滚动的大小。默认是0,没有滚动效果。

@property(nonatomic)         UIEdgeInsets                 contentInset;
// default UIEdgeInsetsZero. add additional scroll area around content
//contentInset增加你在contentSize中指定的内容能够滚动的上下左右区域数量。contentInset.top、contentInset.buttom、contentInset.left、contentInset.right分别表示上面,下面,左边和右边的距离。

@property(nonatomic,assign) id<UIScrollViewDelegate>      delegate;
// default nil. weak reference
//设置代理

@property(nonatomic,getter=isDirectionalLockEnabled) BOOL directionalLockEnabled;
// default NO. if YES, try to lock vertical or horizontal scrolling while dragging
//默认是NO,可以在垂直和水平方向同时运动。当值是YES时,假如一开始是垂直或者是水平运动,那么接下来会锁定另外一个方向的滚动。假如一开始是对角方向移动,则不会禁止某个方向。

@property(nonatomic)         BOOL                         bounces;
// default YES. if YES, bounces past edge of content and back again
//默认是YES,就是滚动超过边界会反弹,有反弹回来的效果。如果是NO,那么滚动到达边界会立即停止

@property(nonatomic)         BOOL                         alwaysBounceVertical;           // default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag vertically
@property(nonatomic)         BOOL                         alwaysBounceHorizontal;         // default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag horizontally
@property(nonatomic,getter=isPagingEnabled) BOOL          pagingEnabled;
// default NO. if YES, stop on multiples of view bounds
//当值是YES会自动滚到subview的边界,默认为NO

@property(nonatomic,getter=isScrollEnabled) BOOL          scrollEnabled;
// default YES. turn off any dragging temporarily
//决定是否可以滚动

@property(nonatomic)         BOOL                         showsHorizontalScrollIndicator;
// default YES. show indicator while we are tracking. fades out after tracking
//滚动时是否显示水平滚动条

@property(nonatomic)         BOOL                         showsVerticalScrollIndicator;
// default YES. show indicator while we are tracking. fades out after tracking
//滚动时是否显示垂直滚动条

@property(nonatomic)         UIEdgeInsets                 scrollIndicatorInsets;
// default is UIEdgeInsetsZero. adjust indicators inside of insets
//设置滚动条的位置

@property(nonatomic)         UIScrollViewIndicatorStyle   indicatorStyle;
// default is UIScrollViewIndicatorStyleDefault
//滚动条的样式,基本只是设置颜色,总共3个颜色:默认、黑、白。

@property(nonatomic)         float                        decelerationRate __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
//设置手指放开后的减速率

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
// animate at constant velocity to new offset
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;
// scroll so rect is just visible (nearest edges). nothing if rect completely visible
//上面这个两个函数用来自动滚到到想要的位置,此过程中设置有动画效果,停止时,触发该函数。当animated为YES的时候有动画效果

- (void)flashScrollIndicators;             // displays the scroll indicators for a short time. This should be done whenever you bring the scroll view to front.

@property(nonatomic,readonly,getter=isTracking)     BOOL tracking;
// returns YES if user has touched. may not yet have started dragging
//当touch后还没有拖动的时候是YES,否则为NO

@property(nonatomic,readonly,getter=isDragging)     BOOL dragging;        // returns YES if user has started scrolling. this may require some time and or distance to move to initiate dragging
@property(nonatomic,readonly,getter=isDecelerating) BOOL decelerating;
// returns YES if user isn‘t dragging (touch up) but scroll view is still moving
//当滚动后,手指放开但是还在继续滚动中。这个时候是YES,其他时候 NO

@property(nonatomic) BOOL delaysContentTouches;
// default is YES. if NO, we immediately call -touchesShouldBegin:withEvent:inContentView:
//当值是YES的时候,用户触碰开始,scroll view要延迟一会,看看是否用户有意图滚动。假如滚到了,那么捕捉touch-down事件,否则就不捕捉。假如值是NO,当用户触碰,scroll view会立即触发touchesSholdBegin:withEvent:inContentView:。默认为YES。

@property(nonatomic) BOOL canCancelContentTouches;
// default is YES. if NO, then once we start tracking, we don‘t try to drag if the touch moves
//当值是YES的时候,用户触碰后,然后在一定时间内没有移动,scrollView发送tracking events,然后用户移动手指足够长度触发滚动事件,这个时候,scrollview发送了touchesCancelled:withEvent:到subview,然后scrollview开始滚动。假如为NO,scrollview发送tracking events后,就算用户移动手指,scrollview也不会滚动。

// override points for subclasses to control delivery of touch events to subviews of the scroll view
// called before touches are delivered to a subview of the scroll view. if it returns NO the touches will not be delivered to the subview
// default returns YES。决定自己是否接收touch事件
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view;

// called before scrolling begins if touches have already been delivered to a subview of the scroll view. if it returns NO the touches will continue to be delivered to the subview and scrolling will not occur
// not called if canCancelContentTouches is NO. default returns YES if view isn‘t a UIControl
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
//开始发送tracking message消息给subview的时候调用这个方法,决定是否发送tracking message消息给subview。假如返回NO,发送,YES则不发送。

@property(nonatomic) float minimumZoomScale;
// default is 1.0。表示能缩最小的倍数

@property(nonatomic) float maximumZoomScale;
// default is 1.0. must be > minimum zoom scale to enable zooming。表示能放最大的倍数

@property(nonatomic) float zoomScale __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);            // default is 1.0
- (void)setZoomScale:(float)scale animated:(BOOL)animated __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);

@property(nonatomic) BOOL  bouncesZoom;
// default is YES. if set, user can go past min/max zoom while gesturing and the zoom will animate to the min/max value at gesture end
//和bounces类似,区别在于:这个效果反映在缩放方面假如缩放超过最大缩放,那么会有反弹效果;假如是NO,则到达最大或者最小的时候立即停止

@property(nonatomic,readonly,getter=isZooming)       BOOL zooming;
// returns YES if user in zoom gesture。当正在缩放的时候是YES,否则为NO

@property(nonatomic,readonly,getter=isZoomBouncing)  BOOL zoomBouncing;
//returns YES if we are in the middle of zooming back to the min/max value。
//当内容放大到最大或者最小的时候值是YES,否则为NO

// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top.
// On iPhone, we execute this gesture only if there‘s one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.
@property(nonatomic) BOOL  scrollsToTop;          // default is YES.

// Use these accessors to configure the scroll view‘s built-in gesture recognizers.
// Do not change the gestures‘ delegates or override the getters for these properties.
@property(nonatomic, readonly) UIPanGestureRecognizer *panGestureRecognizer __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0);
// `pinchGestureRecognizer` will return nil when zooming is disabled.
@property(nonatomic, readonly) UIPinchGestureRecognizer *pinchGestureRecognizer __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0);

@end

@protocol UIScrollViewDelegate<NSObject>

@optional

- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
// any offset changes
//触摸屏幕来滚动画面还是其他的方法使得画面滚动,皆触发该函数

- (void)scrollViewDidZoom:(UIScrollView *)scrollView __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_2); // any zoom scale changes

// called on start of dragging (may require some time and or distance to move)
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
// called on finger up if the user dragged. velocity is in points/second. targetContentOffset may be changed to adjust where the scroll view comes to rest. not called when pagingEnabled is YES
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);

// called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
//触摸屏幕并拖拽画面,再松开,最后停止时,触发该函数

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;   // called on finger up as we are moving
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
 // called when scroll view grinds to a halt
//滚动停止时,触发该函数

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; // called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating

//scroll view还处理缩放和平移手势,要实现缩放和平移,必须实现委托viewForZoomingInScrollView:和scrollViewDidEndZooming:withView:atSacle:两个方法。另外maximumZoomScale和mimimumZoomScale两个属性要不一样
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;     // return a view that will be scaled. if delegate returns nil, nothing happens
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_2); // called before the scroll view begins zooming its content
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale; // scale between minimum and maximum. called after any ‘bounce‘ animations

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;   // return a yes if you want to scroll to the top. if not defined, assumes YES
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;      // called when scrolling animation finished. may be called immediately if already at top

@end

iOS 开发 之 - UIScrollView文档

时间: 2024-11-08 16:02:04

iOS 开发 之 - UIScrollView文档的相关文章

【iOS开发-49】文档注释的插件VVDocumenter的安装和使用

文档注释是/**   */,快捷键是///. 不过这需要安装插件,VVDocumenter. 下载地址:https://github.com/onevcat/VVDocumenter-Xcode (1)安装方法 里面有,最简单的就是下载后,打开VVDocumenter-Xcode.xcodeproj文件,然后CMD+R运行一下,再CMD+Q完全退出Xcode.再次打开Xcode就能用. (2)使用方法 在需要文档注释的上面连续输入三个/,即///,当输入第三个/的时候,它会自动生成文档注释,且很

黑马程序员-Xcode离线帮助文档的安装 ios开发-开发文档安装 isa指针 superclass指针 ios系统分四层:

Xcode离线帮助文档的安装 ios开发-开发文档安装 iOS开发肯定离不开开发文档,苹果有在线帮助文档,xCode其实可以下载模拟器文档和iOS8.1文档的,不过下载的速度实在不敢恭维,而且比较头疼的是不显示下载进度条的,苹果的开发文档都是放在)/应用程序/Xcode.app/Contents/Developer/Documentation/DocSets路径下,该路径下可以看到三个文件,xCode 6.1文档(com.apple.ADC_Reference_Library.Developer

iOS Foundation 框架概述文档:常量、数据类型、框架、函数、公布声明

iOS Foundation 框架概述文档:常量.数据类型.框架.函数.公布声明 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的漂亮人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. Foundation 框架概述文档:常量.数据类型.框架.函数.

VC项目开发之单文档多视图实现-非分割窗口[转]

k_eckel:http://www.mscenter.edu.cn/blog/k_eckel 多视图是VC开发中经常要用到的技术之一,一般地实现单文档多视图有两种方式 1)通过视图分割的技术(使用CSplitterWnd实现),将窗口分割为多个部分,每个部分显示各自显示不同的视图,这种技术实现起来比较简单,并且相关的资料也很多. 2)通过一个文档关联多个视图,窗口显示整个视图. 第二种实现较第一种复杂,这里给出详细的实现方法. Step 1:使用VC 6.0新建一个Project,命名为:Mu

成都接单-网站/APP开发/价格实在/文档完备

接单-网站/APP开发/价格实在/文档完备优势:8年PHP 9年JAVA开发经验采用THINKPHP 和JFINAL ,SBadmin 2框架进行开发完善的开发文档免费一年BUG维护 可签协议,可先预付20%,也可分段付款, 亲 请带好需求文档! QQ 184377367 报价原则1:功能列表2:兼容性3:安全要求等级4:是否需要完善的开发文档5:后台UI是否有要求

IOS..读取本地HTML文档

#import <UIKit/UIKit.h> #import “LoadLocalHtmlViewController.h” @interfaceLoadLocalHtmlViewController : UIViewController { IBOutlet UIWebView*myWebView; } @property(nonatomic,retain) UIWebView *myWebView; -(IBAction)LoadLocalHtmlFile:(id)sender; @en

在某公司时的java开发环境配置文档

1 开发环境配置 1.1.  MyEclipse 配置 1.MyEclipse下载地址:\\server\共享文件\backup\MyEclipse9.0 2.修改工作空间编码为UTF-8,如下图 3.注释配置 类注释配置:如下图 方法注释:如下图 2. 代码书写规范 2.1. Action 所有action类必须继承com.xx.util.BaseAction类,并且加上@Controller注解:对于service层注入,同意在set方法上写@Resource注解.例如 @Controlle

《Java开发学习大纲文档》V6.0

<Java开发大纲学习文档第六版>简介:          该文档是根据企业高级Java从事IT行业多年开发经验上所需要掌握的知识点大纲进行总结汇编,是Java开发工程师必备知识体系,系统化学习针对性非常强,逻辑分析能力非常清晰;技术方面覆盖非常广泛全面,从编程环境安装开始切入,第一阶段从Java基础(Java核心基础+面向对象+多线程+常用类+IO+GUI+网络编程+常用实例)入门,第二阶段深入了解JavaWeb(Oracle.MySQL.MongoDB.MySQL数据库的优化.HTML5.

软件开发的常见文档

软件开发的常见文档 01立项调查报告02立项建议书 03立项评审报告 04项目设计开发任务书 05项目计划 06质量保证计划 07配置管理计划 08需求分析说明书 09概要设计说明书 10详细设计说明书 11数据库设计说明书 12数据库表详细设计 13单元测试计划 14测试脚本 15单元测试报告 16系统测试计划 17验收申请书 18验收评审报告 19客户验收报告 21审核反馈表 22软件评审报告 23变更需求报告 24设计变更报告 26项目管理报告 27项目总结报告 原文地址:https://