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",我在无意中发现了它们所具有的相同的一些用法,先举 ...
随机推荐
- Java中json工具对比分析
Java中几个json工具分析 1, 环境 JDK1.6+IDE(IntelliJ IDEA)+windowsXP+GBK编码 2,分析对象 jackson1.8.2 http://jackson.c ...
- opencv学习笔记-图像叠加、混合
在图像处理中,目标区域定义为感兴趣区域ROI(region of Interest),这是后期图像处理的基础,在获取ROI后,进行一些列的处理.ROI区域在Opencv中就是Rect,先构建Rect, ...
- javascript 可控速度的上下拉菜单
样式部分 <style type="text/css"> *{ margin:0; padding:0; border:none; background:none;} ...
- Fix java version mismatch in windows---stackoverflow
Question: I have the 64bit version of the jdk installed on windows 7. I installed the 32 bit version ...
- Java NIO——Selector机制源码分析---转
一直不明白pipe是如何唤醒selector的,所以又去看了jdk的源码(openjdk下载),整理了如下: 以Java nio自带demo : OperationServer.java Oper ...
- OC-KVO简介
一,概述 KVO,即:Key-Value Observing,它提供一种机制,当指定的对象的属性被修改后,则对象就会接受到通知.简单的说就是每次指定的被观察的对象的属性被修改后,KVO就会自动通知相应 ...
- linux文件系统和mount(硬盘,win分区,光驱,U盘)
fdisk –l查看dos/win/ext2分区(partiton,不是slice,slice是solaris分区) [root@localhost etc]# /sbin/fdisk -l Disk ...
- Android Activity横竖屏转换的生命周期
新创建一个Activity,用来此次测试. 先贴代码 package com.hugo.apj.activitylifetest; import android.support.v7.app.AppC ...
- Css3渐变(Gradients)-径向渐变
CSS3径向渐变-radial-gradient()/repeating-radial-gradient() 径向渐变由它的中心定义. 创建径向渐变,至少定义两种颜色节点,呈现平稳过度的颜色.同时,你 ...
- SQL存储过程传入字段名查询.
根据字段名和对应的值查询. (正确代码):目前发现,需要"分组,排序"等才能解决,如"order by","group by"等. SQL代 ...