zoukankan      html  css  js  c++  java
  • UIScrollerView 的简单使用

    //

    //  RootViewController.m

    //  Lianxi_02

    //

    //  Created by Super man on 15-2-11.

    //  Copyright (c) 2015年 super man. All rights reserved.

    //

    #import "RootViewController.h"

    @interface RootViewController ()<UIScrollViewDelegate>

    {

        UIScrollView *_scrollView;

        UIImageView *_image;

        

    }

    @end

    @implementation RootViewController

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

    {

        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

        if (self) {

            // Custom initialization

        }

        return self;

    }

    - (void)viewDidLoad

    {

        [super viewDidLoad];

        _scrollView=[[UIScrollView alloc]initWithFrame:self.view.bounds];

        [self.view addSubview:_scrollView];

        

        _image=[[UIImageView alloc]init];

        _image.image=[UIImage imageNamed:@"meinv"];

        CGFloat imageW=_image.image.size.width;

        CGFloat imageH=_image.image.size.height;

        _image.frame=CGRectMake(0.0, 0.0, imageW, imageH);

        

        [_scrollView addSubview:_image];

        //滚动视图的尺寸

        _scrollView.contentSize=_image.image.size;

        //隐藏水平、垂直滚动条

        _scrollView.showsHorizontalScrollIndicator=NO;

        _scrollView.showsHorizontalScrollIndicator=NO;

        //增加额外的滚动区域(逆时针,上、左、下、右)

        _scrollView.contentInset=UIEdgeInsetsMake(20, 20, 20, 20);

        //最大比例

        _scrollView.maximumZoomScale=2.0;

        //最小比例

        _scrollView.minimumZoomScale=0.5;

        //实现委托

        _scrollView.delegate=self;

        

        

        // Do any additional setup after loading the view.

    }

    #define UIScrollViewDelegate

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

        

        return _image;

    }

    - (void)didReceiveMemoryWarning

    {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    /*

     #pragma mark - Navigation

     // In a storyboard-based application, you will often want to do a little preparation before navigation

     - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

     {

     // Get the new view controller using [segue destinationViewController].

     // Pass the selected object to the new view controller.

     }

     */

    @end

  • 相关阅读:
    测试可以自动化,日常工作也可以自动化,autoit帮你搞定!
    工作了几年的IT人想要创业,必看的失败经验
    使用autoit,可以节省您很多时间
    美容院会籍管理,看着简单,其实很复杂
    简历,求职求项目,硕士4年工作经验2年管理经验
    maven+svn+hudson+weblogic构建持续集成环境
    快速开发框架V0.001(免费、100%开源)
    进销存管理系统的设计与实现
    窗体的位置startposition manual
    破解网页文章无法复制方法全集合
  • 原文地址:https://www.cnblogs.com/zhuzhushen/p/4286859.html
Copyright © 2011-2022 走看看