IOS Uipageview and Uiscrollview

Source: Internet
Author: User

In iOS development, we will definitely use something like the Welcome interface. You need to turn the page and the following tips dot dot.

In the implementation of iOS, the page turn effect is to use Uiscrollview. And Uipageview just add the following tip dot only.

The following I post detailed implementation is relatively simple:

adview.m//ting3////Created by du Jia Li on 11/17/14.//Copyright (c) 2014 DuPont. All rights reserved.//#import "ADView.h" @interface ADView () <UIScrollViewDelegate> @property (nonatomic, Strong) Uiscrollview *adscrollview; @property (nonatomic, strong) Uipagecontrol *adpagecontrol; @end @implementation ADView-(ID                       ) initWithFrame: (CGRect) frame Andimagepatharr: (Nsarray *) patharr{if (self = [Super Initwithframe:frame]) {        _adscrollview = [[Uiscrollview alloc] Initwithframe:cgrectmake (0, 0, Frame.size.width, frame.size.height)];        _adscrollview.pagingenabled = true;        _adscrollview.bounces = false;        _adscrollview.delegate = self;               _adscrollview.contentsize = Cgsizemake (Frame.size.width * patharr.count, frame.size.height);                             [Self addsubview:_adscrollview]; for (int i = 0; i < Patharr.count; i++) {Uiimageview * Adimageview = [[Uiimageview alloc] Initwithimage:[ui Image ImagewithcontentsoffIle:patharr[i]];            Adimageview.frame = CGRectMake (frame.size.width * I, 0, frame.size.width, frame.size.height);        [_adscrollview Addsubview:adimageview]; } _adpagecontrol = [[Uipagecontrol alloc] Initwithframe:cgrectmake (0, Cgrectgetmaxy (_adscro        Llview.frame)-Frame.size.width, 30];                [_adpagecontrol addtarget:self Action: @selector (Pageturn:) forcontrolevents:uicontroleventalleditingevents];        _adpagecontrol.numberofpages = Patharr.count;        _adpagecontrol.currentpage = 0;                            [Self Addsubview:_adpagecontrol]; } return self;}    -(void) Pageturn: (Uipagecontrol *) sender{cgsize viewsize = _adscrollview.frame.size;    CGRect rect = CGRectMake (sender.currentpage * viewsize.width, 0, Viewsize.width, viewsize.height);    [_adscrollview Scrollrecttovisible:rect Animated:yes]; }-(void) scrollviewdidenddecelerating: (Uiscrollview *) scrollview{cgpoint offset = ScrollView.Contentoffset;    CGRect bounds = scrollview.frame;            _adpagecontrol.currentpage = Offset.x/bounds.size.width; } @end


IOS Uipageview and Uiscrollview

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.