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

  • 相关阅读:
    可变长参数
    函数的参数
    函数
    文件操作
    字符编码
    数据类型的内置方法:集合
    数据类型的内置方法:元组
    数据类型的内置方法:字典
    数据类型内置方法:列表
    js对对象引用
  • 原文地址:https://www.cnblogs.com/zhuzhushen/p/4286859.html
Copyright © 2011-2022 走看看