3, IOS development Uiscrollview Uipagecontroller Nstimer

Source: Internet
Author: User

First, Uiscrollview properties

1. Common Properties

// 移动的位置@property(nonatomicCGPoint contentOffset;// 内容的大小@property(nonatomicCGSize contentSize;// 四边扩展的边距@property(nonatomicUIEdgeInsets contentInset;

2. Other properties

// 弹簧效果@property(nonatomicBOOL bounces;// 是否能滚动@property(nonatomicBOOL scrollEnabled;// 是否隐藏水平滚动条@property(nonatomicBOOL showsHorizontalScrollIndicator;// 是否隐藏垂直滚动条@property(nonatomicBOOL showsVerticalScrollIndicator;

Basic use of 3.UIScrollView

1> 将需要展示的内容添加到UIScrollView中2> 设置UIScrollView的contentSize属性

The reason why 4.UIScrollView cannot scroll

1> 没有设置UIScrollView的contentSize2> scrollEnabledNO;3> userInterfaceEnabledNO4> 没有取消autolayout功能
Second, the agent of Uiscrollview
    • One of the properties in Uiscrollview is that the delegate purpose is to listen to the entire scrolling process and notify its proxy object when scrolling occurs to perform the appropriate action

1. Requirements for becoming an agent

1> 遵守UIScrollViewDelegate协议2> self.scrollview.delegateself;* 通过SB拖线

2. How to drag and drop a scrolling agent

// 用户开始拖拽时调用- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;// 滚动到某个位置时调用- (void)scrollViewDidScroll:(UIScrollView *)scrollView;// 用户结束拖拽时调用- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

3. Proxy method for Scaling

// 返回需要缩放的视图控件- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;// 准备开始缩放的调用- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view// 正在缩放的时候调用- (void)scrollViewDidZoom:(UIScrollView *)scrollView

1> Scaling Implementation Steps

* 设置代理对象* 设置minimumZoomScale:缩放的最小比例* 设置maxmumZoomScale:放大的最大比例* 实现代理的方法
Third, Uipagecontrol of the page
    • Paging: Achieving the effect of a similar picture carousel
      Premise: To set the Pageenabled property of Uiscrollview to Yes, in order to enhance the paging effect, work with Uipagecontrol

1. Common Properties

//Total pages@property(nonatomic)NsintegerNumberofpages;//Current page@property(nonatomic)NsintegerCurrentPage;//When there is a page, whether to hide the page number indicator@property(nonatomic)BOOLHidesforsinglepage;color of//other page indicator@property(nonatomic, retain)Uicolor*pageindicatortintcolor;//color of the current page indicator@property(nonatomic, retain)Uicolor*currentpageindicatortintcolor;

2. Monitoring methods

addTarget:selfaction:@selector(pageChanged:forControlEvents:UIControlEventValueChanged];
Iv. Use of Nstimer

Function: Specifies the time to perform the specified task, performing the specified task at intervals of time

1. Start a timed task

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTargetselector:(SEL)aSelectoruserInfo:(id)userInforepeats:(BOOL)yesOrNo;// 每隔ti秒,调用一次aTarget的aSelector方法,yesOrNo决定了是否重复执行这个方法

2. Canceling a task

- (void)invalidate;// 一旦定时器被停止了,就不能重现开启了,只能再创造一个定时器

3. Add the timer to the run cycle

[[NSRunLoop currentRunLoop]addTimer:self.timerforMode:NSRunLoopCommonModes];
    • There are two modes of running a loop:
默认的运行循环模式:NSDefaultRunLoopMode监听滚动模式:NSRunLoopCommonModes

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

3, IOS development Uiscrollview Uipagecontroller Nstimer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.