zoukankan      html  css  js  c++  java
  • 20141211笔记(UIImageView 设置内容的Mode的方法UICollectionViewCell Custom的方法ios modal segue code)

    1、UIImageView 设置内容的Mode的方法
    imageView.contentMode = UIViewContentModeScaleAspectFill;

    2、UICollectionViewCell Custom的方法
    CustomUICollectionViewCell.m
    - (id)initWithFrame:(CGRect)frame{
        if (self = [super initWithFrame:frame]) {
            [self initUI];
        }
        return self;
    }
    - (void)initUI{ 
      //TODO }

    然后在collectionView中注册这个CustomUICollectionViewCell

      UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init];
        collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
        [collectionView setTranslatesAutoresizingMaskIntoConstraints:NO];
        [collectionView setBackgroundColor:[UIColor clearColor]];
        [collectionView registerClass:[CustomCollectionViewCell class] forCellWithReuseIdentifier:@"MY_CELL"];
        collectionView.dataSource = self;
        collectionView.delegate = self;

    最后在datasource函数中复用Cell

    - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
        CustomCollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
        
        return cell;
    }

    这就是CollectionViewCell的Custom流程

    3、ios modal segue code

    - (IBAction)pushMyNewViewController
    {
        MyNewViewController *myNewVC = [[MyNewViewController alloc] init];
    
        // do any setup you need for myNewVC
    
        [self presentModalViewController:myNewVC animated:YES];//被弃用

        [self presentViewController:viewController animated:YES completion:nil];//被这个代替

    }

    [self dismissViewControllerAnimated:YES completion:nil];  //dismiss view

     
  • 相关阅读:
    分治
    #include<algorithm>
    c++标准模板库的使用
    mysql_day03
    mysql_day02
    mysql_day01
    mongodb的安装
    迭代器和生成器简单介绍
    File文件操作
    数据类型
  • 原文地址:https://www.cnblogs.com/scaptain/p/4156553.html
Copyright © 2011-2022 走看看