iOS Learning-ScrollView (Image Viewer)

Source: Internet
Author: User

yjviewcontroller.m//07-scrollview-View large image////Created by Jacky-mac on 15-6-17.//Copyright (c) 2015 www.train.com. All rights reserved.//#import "YJViewController.h" @interface Yjviewcontroller () <uiscrollviewdelegate>@ Property (Strong, Nonatomic) Iboutlet Uiscrollview *scrollview; @property (nonatomic,strong) Uiimageview *imageview;// Assume that the image is a @property (nonatomic,strong) UIImage *image obtained from the network, @end @implementation yjviewcontroller//image setter-(void)        SetImage: (UIImage *) image{_image = image;        Sets the contents of the image view Self.imageView.image = image;        Let the image view automatically resize according to the image [Self.imageview SizeToFit]; Tell ScrollView the actual size of internal content self.scrollView.contentSize = Image.size;}        -(Uiimageview *) imageview{if (_imageview ==nil) {_imageview = [[Uiimageview alloc] init];    [Self.scrollview Addsubview:_imageview]; } return _imageview;} -(Uiscrollview *) scrollview{if (_scrollview = = nil) {_scrollview = [[Uiscrollview alloc] Initwithframe:self.v iew.bOunds];                Set properties//set margin Self.scrollView.contentInset = Uiedgeinsetsmake (20, 20, 20, 20);                Do not display horizontal scrolling indicator self.scrollView.showsHorizontalScrollIndicator = no;                Do not display vertical scrolling indicator self.scrollView.showsVerticalScrollIndicator = no;        Offset position self.scrollView.contentOffset = cgpointmake (0,-100);                   Cancels the spring effect, the content is fixed, does not want to appear the spring effect when//does not mix with the bounds attribute self.scrollView.bounces = no;                   Set proxy _scrollview.delegate = self;        Set maximum/minimum scaling _scrollview.maximumzoomscale = 2.0;                _scrollview.minimumzoomscale = 0.2;            [Self.view Addsubview:_scrollview]; } return _scrollview;}        -(void) viewdidload{[Super Viewdidload]; Set Image self.image = [UIImage imagenamed:@ "Minion"];} The proxy method for the #pragma mark-uiscrollview/** 1> Sets the proxy 2> specifies the maximum, minimum scale representation that ScrollView is the "return value" of the proxy method that can be scaled is actually the controller tells the scrolling view that the UI is scaled ImageView *///told SCRollview to zoom the view is who, the specific scaling implementation, is done by the ScrollView//1> ScrollView to know to zoom who-(UIView *) Viewforzoominginscrollview: ( Uiscrollview *) scrollview{return self.imageview;} @end

iOS Learning-ScrollView (Image Viewer)

Related Article

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.