Ios_7_scrollview Large Map Zoom

Source: Internet
Author: User

Finally:



BeyondViewController.h

  beyondviewcontroller.h//  7_scrollview big Picture Show////  Created by Beyond on 14-7-24.//  Copyright (c) 2014 Com.beyond. All rights reserved.//#import <UIKit/UIKit.h> @interface beyondviewcontroller:uiviewcontroller-(ibaction) Upbtnclick: (ID) sender; @end



Beyondviewcontroller.m

beyondviewcontroller.m//7_scrollview Large Figure show////Created by Beyond on 14-7-24.//Copyright (c) 2014 Com.beyond. All rights reserved.//#import "BeyondViewController.h" @interface Beyondviewcontroller () <uiscrollviewdelegate        >{Uiscrollview *_scrollview; Which of the internal controls to scale is Uiimageview *_imgview;}    @end @implementation beyondviewcontroller-(void) viewdidload{[Super Viewdidload];    Uiimageview//1, class method creation control//Uiimageview *imgview = [[Uiimageview alloc]init]; 2, control details//NSString *imgname = [NSString stringwithformat:@ "hd.jpg"];//imgview.image = [UIImage imagenamed:imgname ];//cgfloat IMGW = imgview.image.size.width;//cgfloat imgh = imgview.image.size.height;//ImgView.frame = CGRec        Tmake (0, 0, IMGW, IMGH);                or high-speed creation, a sentence above the top of the 6 code _imgview = [[Uiimageview alloc]initwithimage:[uiimage imagenamed:@ "hd.jpg"]];    1, instantiate Uiscrollview _scrollview = [[Uiscrollview alloc]init]; 2, set ScrollView visual size, content size, etc Properties//_scroLlview.frame = CGRectMake (0, 0, 320, 480);    _scrollview.frame = Self.view.bounds; _scrollview.contentsize = _imgview.image.size;    The most important is the scrolling area _scrollview.showshorizontalscrollindicator = NO;    _scrollview.showsverticalscrollindicator = NO;    _scrollview.bounceszoom = NO;    _scrollview.bounces = YES; Scrollview.contentoffset is a point, X (left) and Y (above), the value is ScrollView inside the large picture drag displacement, relative to the ScrollView display form of the top left corner//top left and right counterclockwise to the boundary, not back, more out    Distance//Scrollview.contentinset = Uiedgeinsetsmake (5, 10, 20, 40);    3, add Imgeview to ScrollView [_scrollview Addsubview:_imgview];    4, add ScrollView to Self.view//[Self.view Addsubview:_scrollview];                Minor bug solved, the button on the interface was completely obscured [self.view insertsubview:_scrollview atindex:0];            /* 4.scrollView Implementation zoom (pinch gesture) Four step 1, set Proxy to current controller 2, Proxy honor Agreement <UIScrollViewDelegate> 3, the proxy implementation of the Protocol in the method Viewforzoominginscrollview, tell ScrollView to scale is which of its internal control 4,scrollview set the maximum minimum scaling ratio can be */_scrol Lview.delegate = self;    _scrollview.minimumzoomscale = 0.3;                        _scrollview.maximumzoomscale = 2.0; The}//proxy implements the method in the protocol, telling ScrollView to scale which control is inside it-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) scrollview{return _ Imgview;} -(Ibaction) Upbtnclick: (ID) Sender {//Scrollview.contentoffset is a point, X (left) and Y (above), the value is the large picture drag displacement inside the ScrollView, The upper-left corner of the display form relative to ScrollView [UIView animatewithduration:0.3 animations:^{//The following three steps are OC Standard code, since OC does not agree to directly fix the value of the member of the struct attribute in the object, to        Cgpoint offset = _scrollview.contentoffset by a temporary structural body variable in the middle;        if (Offset.y + >= _scrollview.contentsize.height-_scrollview.frame.size.height) {return;        } Offset.y + = 80;    _scrollview.contentoffset = offset; }];} @end

ScrollView's Contentoffset



The ScrollView principle is by dragging the big picture inside its




Ios_7_scrollview Large Map Zoom

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.