QBImagePickerController 用法
//
// 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 用法的更多相关文章
- EditText 基本用法
title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...
- jquery插件的用法之cookie 插件
一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...
- Java中的Socket的用法
Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- python enumerate 用法
A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...
- [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...
- 【JavaScript】innerHTML、innerText和outerHTML的用法区别
用法: <div id="test"> <span style="color:red">test1</span> tes ...
- chattr用法
[root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...
- 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)
vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...
随机推荐
- 365. Water and Jug Problem
莫名奇妙找了个奇怪的规律. 每次用大的减小的,然后差值和小的再减,减减减减减减到差值=0为止.(较小的数 和 差值 相等为止,这么说更确切) 然后看能不能整除就行了. 有些特殊情况. 看答案是用GCD ...
- javascript从入门到精通(二)
第二章.数据结构 JavaScript脚本语言的数据结构包括:标识符.关键字.常量.变量等. 标识符:就是一个名称.在JavaScript用来命名变量和函数或者用作JavaScript代码中某些循环的 ...
- WinForm中关于控件焦点的问题
方法一: 在打开一个窗体时,我们往往需要设置焦点让光标出现在我们希望它出现的位置上. 这时我们可以在窗体的Activated事件中设置焦点 例如我们希望光标在打开窗体的时候出现在textBox1上,我 ...
- StopWatch
附件 http://download.csdn.net/detail/teststudio/6575241 主窗体UNIT unit MainForm; interface uses Windows, ...
- 在LaTeX里插入全页的pdf 分类: LaTex 2015-02-04 17:20 142人阅读 评论(0) 收藏
要帮女友排版毕业论文,需要插入封面,省时省力的方法就是把学校给的Word封面保存成PDF然后插入到Latex文档中. 首先添加下面的宏: \usepackage[final]{pdfpages} 然后 ...
- eclipse下maven插件的安装
最近公司项目要求使用maven来进行项目的管理开发,在这里记录一下eclipse下maven插件的安装. maven插件在eclipse下安装害得我挺恼火的. 我想用最简单的那种方式--在线安装: 通 ...
- 深入分析 Java I/O 的工作机制--转载
Java 的 I/O 类库的基本架构 I/O 问题是任何编程语言都无法回避的问题,可以说 I/O 问题是整个人机交互的核心问题,因为 I/O 是机器获取和交换信息的主要渠道.在当今这个数据大爆炸时代, ...
- 比较好的自学IT的网站
其实这是我在知乎的一个回答,由于收藏人数众多,我想也许对有些初学者有用,故同步到Blog.此文章和知乎答案将不定期同步更新(知乎答案传送门). 入门与进阶: 学堂在线-最大的中文慕课(MOOC)平台学 ...
- CSS Clip剪切元素实例
一.实例1: .fixed { position: fixed; width: 382px; height: 100px; background: red; border: 1px solid blu ...
- HTML5 ArrayBufferView之DataView
DataView视图 如果一段数据包括多种类型(比如服务器传来的HTTP数据),这时除了建立ArrayBuffer对象的复合视图以外,还可以通过DataView视图进行操作. DataView视图提供 ...