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",我在无意中发现了它们所具有的相同的一些用法,先举 ...
随机推荐
- stickyListHeaders框架的使用
最近在Demo中使用到了stickyListHeaders框架实现悬停效果 比较好用 在xml中 <se.emilsjolander.stickylistheaders.StickyListHe ...
- centos_6.7_系统初始化
#!/bin/bash #****************************************************************# # ScriptName: acfunin ...
- python 写的http后台弱口令爆破工具
今天来弄一个后台破解的Python小程序,哈哈,直接上代码吧,都有注释~~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...
- poj 2926 Requirements
点击打开poj 2926 思路: n维空间计算最远的曼哈顿距离 分析: 1 题目给定n个5维的点,要求最远的曼哈顿距离 2 求最远曼哈顿距离,对于一个n维的空间,其中两点的曼哈顿距离为:|x1-x2| ...
- 往另外1个ListView中添加当前选中的项目
//往另外1个ListView中添加当前选中的项目 function AddSelItems(listview1:TListView;ListView2:TListView):Boolean; ...
- 11.1 morning
完美的序列(sequence)Time Limit:1000ms Memory Limit:64MB题目描述LYK 认为一个完美的序列要满足这样的条件:对于任意两个位置上的数都不相同.然而并不是所有的 ...
- 转换字符串格式,可用于sql in
/// <summary> /// 转换字符串格式,可用于sql in /// </summary> /// <param name="lst"> ...
- hadoop集群环境搭建之zookeeper集群的安装部署
关于hadoop集群搭建有一些准备工作要做,具体请参照hadoop集群环境搭建准备工作 (我成功的按照这个步骤部署成功了,经实际验证,该方法可行) 一.安装zookeeper 1 将zookeeper ...
- Spire.Barcode好用的条码生在组件
由于项目的需要,今天在网上找了一下条码的组件,发现了一个简单易用的组件,使用简单,几句代码就搞定了.
- jquery选择器取值和url正则匹配
用到的简单jquery知识,简单总结一下,一是能加深自己的记忆,二是方便自己以后查看.常言道"好记性不如烂笔头",要养成常总结.常记录的好习惯.慢慢的发现jquery很有意思,很强 ...