//
// ViewController.m
// QBImagePickerControllerDemo
//
// Created by Tanaka Katsuma on 2013/12/30.
// Copyright (c) 2013年 Katsuma Tanaka. All rights reserved.
// #import "ViewController.h"
#import <AssetsLibrary/AssetsLibrary.h> @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad]; if (![QBImagePickerController isAccessible]) {
NSLog(@"Error: Source is not accessible.");
}
} #pragma mark - UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
QBImagePickerController *imagePickerController = [[QBImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.allowsMultipleSelection = (indexPath.section == ); if (indexPath.section == ) {
switch (indexPath.row) {
case :
imagePickerController.minimumNumberOfSelection = ;
break; case :
imagePickerController.maximumNumberOfSelection = ;
break; case :
imagePickerController.minimumNumberOfSelection = ;
imagePickerController.maximumNumberOfSelection = ;
break; default:
break;
}
} if (indexPath.section == && indexPath.row == ) {
[self.navigationController pushViewController:imagePickerController animated:YES];
} else {
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:imagePickerController];
[self presentViewController:navigationController animated:YES completion:NULL];
}
} - (void)dismissImagePickerController
{
if (self.presentedViewController) {
[self dismissViewControllerAnimated:YES completion:NULL];
} else {
[self.navigationController popToViewController:self animated:YES];
}
} #pragma mark - QBImagePickerControllerDelegate - (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didSelectAsset:(ALAsset *)asset
{
NSLog(@"*** qb_imagePickerController:didSelectAsset:");
NSLog(@"%@", asset);
[self dismissImagePickerController];
} - (void)qb_imagePickerController:(QBImagePickerController *)imagePickerController didSelectAssets:(NSArray *)assets
{
NSLog(@"*** qb_imagePickerController:didSelectAssets:");
NSLog(@"%@", assets); [self dismissImagePickerController];
} - (void)qb_imagePickerControllerDidCancel:(QBImagePickerController *)imagePickerController
{
NSLog(@"*** qb_imagePickerControllerDidCancel:"); [self dismissImagePickerController];
} @end

启动测试程序 会有一个闪退 需要修改 QBAssetsCollectionViewController.m

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
if (kind == UICollectionElementKindSectionFooter) {
QBAssetsCollectionFooterView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:@"FooterView"
forIndexPath:indexPath]; switch (self.filterType) {
case QBImagePickerControllerFilterTypeNone:{
NSString *format;
if (self.numberOfPhotos == ) {
if (self.numberOfVideos == ) {
format = @"format_photo_and_video";
} else {
format = @"format_photo_and_videos";
}
} else if (self.numberOfVideos == ) {
format = @"format_photos_and_video";
} else {
format = @"format_photos_and_videos";
}
NSLog(@"%@",NSLocalizedStringFromTableInBundle(format,\
@"QBImagePickerController",\
[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"QBImagePickerController" ofType:@"bundle"]],\
nil)); footerView.textLabel.text = [NSString stringWithFormat:@"%ld Photo, %ld Video",
(unsigned long)self.numberOfPhotos,\
(unsigned long)self.numberOfVideos\
];
break;
} case QBImagePickerControllerFilterTypePhotos:{
// NSString *format = (self.numberOfPhotos == 1) ? @"format_photo" : @"format_photos";
// footerView.textLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(format,
// @"QBImagePickerController",
// [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"QBImagePickerController" ofType:@"bundle"]],
// nil),
// self.numberOfPhotos
// ];
footerView.textLabel.text = [NSString stringWithFormat:@"%ld Photo, %ld Video",
(unsigned long)self.numberOfPhotos,\
(unsigned long)self.numberOfVideos\
];
break;
} case QBImagePickerControllerFilterTypeVideos:{
// NSString *format = (self.numberOfVideos == 1) ? @"format_video" : @"format_videos";
// footerView.textLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTableInBundle(format,
// @"QBImagePickerController",
// [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"QBImagePickerController" ofType:@"bundle"]],
// nil),
// self.numberOfVideos
// ]; footerView.textLabel.text = [NSString stringWithFormat:@"%ld Photo, %ld Video",
(unsigned long)self.numberOfPhotos,\
(unsigned long)self.numberOfVideos\
];
break;
}
} return footerView;
} return nil;
}

https://github.com/questbeat/QBImagePicker

QBImagePickerController 用法的更多相关文章

  1. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  2. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  3. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  4. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  5. python enumerate 用法

    A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...

  6. [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结

    本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...

  7. 【JavaScript】innerHTML、innerText和outerHTML的用法区别

    用法: <div id="test">   <span style="color:red">test1</span> tes ...

  8. chattr用法

    [root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...

  9. 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)

    vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...

随机推荐

  1. Java 执行jar linux 实例

    需求:通过执行jar的方式 ,把某个文件路径下的用户数据同步到redis 1.main 函数 public class Main { private static Logger logger = Lo ...

  2. ArrayList and LinkedList

    ArrayList and LinkedList List代表一种线性表的数据结构,ArrayList则是一种顺序存储的线性表.ArrayList底层采用数组来保存每个集合元素,LinkedList则 ...

  3. OMCS的语音视频带宽占用

    OMCS的语音.视频.电子白板.远程桌面等功能对网络带宽的要求分别如何了? 我们先假设一种常见的场景:假设N个在线用户同时进行1对1的多媒体沟通(即分为N/2组),在不考虑P2P通道的情况下,带宽的大 ...

  4. CBO学习----03--选择率(Selectivity)

    第3章 单表选择率(Single Table Selectivity) Selectivity是优化器估算Rows(Cards)的重要依据. /**************************** ...

  5. Seeking USB Serial Com Port in Windows Automatically : via PID VID

    After you read previous article, you might know how to operate a com port in Windows.    But that ex ...

  6. javascript中的稀疏数组(sparse array)和密集数组

    学习underscore.js数组相关API的时候.遇到了sparse array这个东西,曾经没有接触过. 这里学习下什么是稀疏数组和密集数组. 什么是密集数组呢?在java和C语言中,数组是一片连 ...

  7. QT+QT creator+OpenCV图像灰度化

    1).pro文件 #------------------------------------------------- # # Project created by QtCreator 2014-05 ...

  8. 利用ssh传输文件 分类: 服务器搭建 Raspberry Pi 2015-04-12 18:47 58人阅读 评论(0) 收藏

    在linux下一般用scp这个命令来通过ssh传输文件. 1.从服务器上下载文件 scp username@servername:/path/filename /var/www/local_dir(本 ...

  9. div css背景图片不显示

    我们在写页面时,为了便于维护,css样式通常都是通过link外部导入html的,有时在css中写入背景图片时,此时背景图片的路径应该是相对css文件的.比如,此时的文件有index.html,css. ...

  10. AIX系统上压缩与解压文件

    压缩. 命令格式: #tar -cvf (或xvf)+文件名+设备 C:是本地到其他设备 x:是其他设备到本地 r:是追加,比如打包时,将其他文件追加进来使用该参数. t:显示tar包里的内容,但还原 ...