zoukankan      html  css  js  c++  java
  • UICollectionView实现的图片的多选效果(本人已封装好,简单操作)

    github 下载demo:https://github.com/MartinLi841538513/MartinDemos (一切以demo为准)

    先说操作,有时间再说我的设计原理。

    两种模式:

    模式一:getImageMode,可从相册或拍照获取图片,并可全屏浏览已选图片。

    模式二:BrowseImageMode,可查看网络图片,本地图片,可全屏浏览这些图片。

    我的操作是基于ELCImagePickerController,AFNetWorking第三方的,以及自己之前封装的MartinLiPageScrollView,所以先导入

    pod 'ELCImagePickerController', '~> 0.2.0'

    pod 'AFNetworking', '~> 2.5.0'

    再从,从MartinDemos中导入ELCImagePickerHelp文件夹和MartinLiPageScrollView文件夹,这个文件夹里面是我封装的。

    详细步骤如下:

    现在的使用就很简单了(这里我只用了模式一)

    .h

    #import <UIKit/UIKit.h>
    @interface MLMutiImagesChooseViewController : UIViewController
    @property (weak, nonatomic) IBOutlet UIView *collectionview;
    @property (weak, nonatomic) IBOutlet NSLayoutConstraint *collectionviewHeight;
    @end

    .m 这里注意MLMutiImagesChoosenViewController最好是要设置成全局的,因为你肯定是需要在后面某地地方获取到collectionview得images的。

    #import "MLMutiImagesChooseViewController.h"
    #import "MLMutiImagesChoosenViewController.h"
    @interface MLMutiImagesChooseViewController ()
    {
        MLMutiImagesChoosenViewController *mutiImagesContoller;
    }
    @end
    
    @implementation MLMutiImagesChooseViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MLMutiImagesViewController" bundle:nil];//(必选)
        mutiImagesContoller = [storyboard instantiateViewControllerWithIdentifier:@"MLMutiImagesChoosenViewController"];//(必选)
        mutiImagesContoller.fatherController = self;//(必选)
        mutiImagesContoller.imageMode = getImagesMode;//(必选)
        mutiImagesContoller.superView = self.collectionview;//(必选)
        mutiImagesContoller.collectionviewHeight = self.collectionviewHeight.constant;//(必选)
        [self addChildViewController:mutiImagesContoller];//(必选)
        [self.collectionview addSubview: mutiImagesContoller.collectionView];//(必选)
    }
    
    - (IBAction)showCountAction:(id)sender {
        self.showCountLabel.text = [NSString stringWithFormat:@"%d",mutiImagesContoller.chooseImages.count];
    }
    @end

     

     

  • 相关阅读:
    sql注入漏洞与防范
    微信小程序-工具,弹出当前系统代理不是安全代理处理方法
    微信小程序-02 小程序关注组件
    微信小程序-01 小数保留二位
    http 转hhttps
    php 函数-ksort
    iOS 原生二维码扫描
    iOS 打包错误 all-product-headers.yaml' not found
    iOS Tableview点击cell 会往上跳
    WKWebView 使用
  • 原文地址:https://www.cnblogs.com/MartinLi841538513/p/4175512.html
Copyright © 2011-2022 走看看