ScrollView/ScrollViewDelegate

UIScrollView

1.contentOffset

/** 内容向外偏移,只在初始状态有效,拉拽后偏移量变回0*/

@property(nonatomic) CGPointcontentOffset

2.contentSize

/** 内容大小*/

@property(nonatomic) CGSizecontentSize

3.contentInset

/** 内容向内偏移,一直有效*/

@property(nonatomic) UIEdgeInsetscontentInset

4.scrollEnabled

/** 滚动可否*/

@property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabled

5.directionLockEnabled

/** 是否支持同一时间垂直水平同时可拉拽,默认支持*/

@property(nonatomic, getter=isDirectionalLockEnabled) BOOL directionalLockEnabled

Discussion

If this property is NO, scrolling is permitted in both horizontal and vertical directions. If this property is YES and the user begins dragging in one general direction (horizontally or vertically), the scroll view disables scrolling in the other direction. If the drag direction is diagonal, then scrolling will not be locked and the user can drag in any direction until the drag completes. The default value is NO

6.pageEnabled

/** 滚动时最后会停在整数倍位置*/

@property(nonatomic, getter=isPagingEnabled) BOOL pagingEnabled

7.bounces

/** 遇到边界是否会碰撞返回,默认YES*/

@property(nonatomic) BOOL bounces

8.decelerationRate

/** 滚动后减速的速度*/

@property(nonatomic) CGFloatdecelerationRate

Discussion

Your application can use the UIScrollViewDecelerationRateNormal and UIScrollViewDecelerationRateFast constants as reference points for reasonable deceleration rates.

9.tracking/dragging/decelerating

/** tracking发生在刚接触屏幕,dragging发生在拖拽时,decelerating发生在手松开后还滚动的时候*/

@property(nonatomic, readonly, getter=isTracking) BOOL tracking

@property(nonatomic, readonly, getter=isDragging) BOOL dragging

@property(nonatomic, readonly, getter=isDecelerating) BOOL decelerating

10.indicatorStyle

/** 滚动条Style*/

@property(nonatomic) UIScrollViewIndicatorStyle indicatorStyle

默认Default样式

typedef enum : NSInteger {

UIScrollViewIndicatorStyleDefault,

UIScrollViewIndicatorStyleBlack,

UIScrollViewIndicatorStyleWhite

} UIScrollViewIndicatorStyle;

11.scrollIndicatorInsets

/** 滚动条内嵌距离*/

@property(nonatomic) UIEdgeInsetsscrollIndicatorInsets

12.showsHorizontalScrollIndicator/VerticalScrollIndicator

/** 是否显示滚动条*/

@property(nonatomic) BOOL showsHorizontalScrollIndicator

@property(nonatomic) BOOL showsVerticalScrollIndicator

13.flashScrollIndicators

/** 显示滚动条在最前面时调用*/

- (void)flashScrollIndicators

Discussion

You should call this method whenever you bring the scroll view to front.

14.delegate

/** 代理*/

@property(nonatomic, assign) id< UIScrollViewDelegate> delegate

Discussion

The delegate must adopt the UIScrollViewDelegate protocol.

15.keyboardDismissMode

/** 键盘消失时间*/

@property(nonatomic) UIScrollViewKeyboardDismissMode keyboardDismissMode

默认None

typedef enum : NSInteger {

UIScrollViewKeyboardDismissModeNone,

UIScrollViewKeyboardDismissModeOnDrag,

UIScrollViewKeyboardDismissModeInteractive

}UIScrollViewKeyboardDismissMode;

UIScrollViewDelegate

1.Dragging and Scrolling

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView

The scroll view calls this method at the end of its implementations of the setContentOffset:animated: and scrollRectToVisible:animated: methods, but only if animations are requested.

2.Zooming

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

Return Value

A UIView object that will be scaled as a result of the zooming gesture. Return nil if you don’t want zooming to occur.

- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale

- (void)scrollViewDidZoom:(UIScrollView *)scrollView

 

时间: 2024-10-17 19:24:48

ScrollView/ScrollViewDelegate的相关文章

ScrollView分栏视图分析

代码精华部分如下: //1.添加scrollView /* 1). 添加一个scrollView; 2).创建关注.热门.附近三个控制器. 3). 存储它们的名字到数组中,遍历并放到本控制器里. 4).设置scrollView的contentSize. 5).设置scrollview的偏移量. 6).调用当停止动画的方法设置为当前的scrollView.(应该是停止拖拽的方法)*/ NSArray *controls = @[@"STRFollowViewController",@&q

Cocos2d-x 3.2 大富翁游戏项目开发-第五部分 单机游戏-级别选择ScrollView

于MenuScene.cpp 点击单机游戏后会调用 Director::getInstance()->pushScene(MapChooseScene::createScene()); 进入到关卡选择界面,我们採用ScrollView控件制作这个界面 因为scrollview拖动后,位置比較任意,我想是拖动到第二张图片,就完整的显示第二张图片,不要产生偏离位置的现象.所以在移动之后须要进行位置的校正,写了一个adjustScrollView()方法,用来进行该调整. 详细代码例如以下: MapC

Cocos2d-x 3.2 大富翁游戏项目开发-第五部分 单机游戏-关卡选择ScrollView

在MenuScene.cpp 点击单机游戏后会调用 Director::getInstance()->pushScene(MapChooseScene::createScene()); 进入到关卡选择界面,我们采用ScrollView控件制作这个界面 由于scrollview拖动后,位置比较随意,我想是拖动到第二张图片,就完整的显示第二张图片,不要产生偏离位置的现象,所以在移动之后需要进行位置的校正,写了一个adjustScrollView()方法,用来进行该调整. 具体代码如下: MapCho

Cocos2dx 小技巧(十四)ScrollView实现缩放效果

这阶段心绪比較乱,所以这篇开头就不扯淡了.(谁说大姨夫来了我跟谁急!~~)说到大姨夫我突然想到英雄联盟有个美女讲解叫伊芙蕾亚,她的堂弟ID居然叫:姨夫累呀,好笑吧(呵呵,有点冷~~额,我都说不扯淡了).------------前天有个网友问我一些关于scrollView的使用方法,因为在QQ上实在讲不清,所以就利用晚上的时间写这篇博客出来了.本篇要实现的功能是用scrollView 拖动对象时,对象移动到某个固定范围会有放大.缩小的效果.以下開始.在进入正题前我先简短的介绍下scrollView

cocos2d-x-3.3 中采用extension的ScrollView实现纵向分页

1 // 2 // extensionScrollView.h 3 // VerticalScroll 4 // 5 // Created by students on 16/1/7. 6 // 7 // 8 9 #ifndef __VerticalScroll__extensionScrollView__ 10 #define __VerticalScroll__extensionScrollView__ 11 12 #include <stdio.h> 13 #include <co

cocos2dx ScrollView不影响滑动,取消弹性小技巧

有时候需要用到ScrollView 但是又不想有那烦人的弹性效果,自然会想到setBounds(false),可是实践过后会发现,这个函数把滑动惯性也给取消了,于是就是你滑多少,滚动多少,用户体验极差... 解决这个方法很简单: 1. 继承ScrollViewDelegate 2. 实现虚函数 virtual void scrollViewDidScroll(ScrollView* view); 然后函数实现如下 void EquipShopItemLayer::scrollViewDidScr

【转载】Cocos2dx 小技巧(十四)ScrollView实现缩放效果

Cocos2dx 小技巧(十四)ScrollView实现缩放效果 这阶段心绪比较乱,所以这篇开头就不扯淡了.(谁说大姨夫来了我跟谁急!~~)说到大姨夫我突然想到英雄联盟有个美女解说叫伊芙蕾亚,她的堂弟ID竟然叫:姨夫累呀,好笑吧(呵呵,有点冷~~额,我都说不扯淡了). ------------前天有个网友问我一些关于scrollView的用法,由于在QQ上实在讲不清,所以就利用晚上的时间写这篇博客出来了.本篇要实现的功能是用scrollView 拖动对象时,对象移动到某个固定范围会有放大.缩小的

从零开始のcocos2dx生活(十)ScrollView

目录 简介 基础变量 ScrollViewDelegate Direction _dragging _container _touchMoved _bounceable _touchLength 方法 create setContentSize deaccelerateScrolling maxContainerOffset 和 minContainerOffset 触摸的各阶段 onTouchBegan onTouchMoved onTouchEnded 简介 scrollView是在一定可视

Android零基础入门第61节:滚动视图ScrollView

原文:Android零基础入门第61节:滚动视图ScrollView 前面几期学习了ProgressBar系列组件.ViewAnimator系列组件.Picker系列组件和时间日期系列组件,接下来几期继续来学习常见的其他组件. 一.ScrollView概述 从前面的学习有的同学可能已经发现,当拥有很多内容时屏幕显示不完,显示不全的部分完全看不见.但是在实际项目里面,很多内容都不止一个屏幕宽度或高度,那怎么办呢?那就需要本节学习的ScrollView来完成. 在默认情况下,ScrollView只是