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",我在无意中发现了它们所具有的相同的一些用法,先举 ...
随机推荐
- BZOJ 3262 陌上花开 CDQ分治
= =原来复杂度还是nlog^2(n) Orz 被喷了 #include<cstdio> #include<cstdlib> #include<algorithm> ...
- hdu1043Eight (经典的八数码)(康托展开+BFS)
建议先学会用康托展开:http://blog.csdn.net/u010372095/article/details/9904497 Problem Description The 15-puzzle ...
- hive 配置文件以及join中null值的处理
一.Hive的參数设置 1. 三种设定方式:配置文件 · 用户自己定义配置文件:$HIVE_CONF_DIR/hive-site.xml · 默认配置文件:$HIVE_CONF_DIR/hi ...
- [RxJS] Transformation operator: buffer, bufferCount, bufferTime
This lesson will teach you about another horizontal combination operator: buffer and its variants. B ...
- StopWatch的用法
在学习spring的时候,看到关于统计时间的类,比较好奇,就记录下来,以便以后用到可以直接使用 org.springframework.util.StopWatch StopWatch该类在统计时间的 ...
- Service 如何知道caller
重写Binder的onTransact方法 1 you need to do that in Binder#onTransact method, this is a good place for ...
- Struts2 ValueStack
一.作用 可以作为一个数据中转站,用在前台和后台数据传递 二.生命周期 ValueStack的生命周期是随着request的创建而创建,随request的销毁而销毁. 三.结构 OgnlValueSt ...
- 关于NetworkInfo对象的isConnected()与isAvailable()
public class MainActivity extends Activity{ /** Called when the activity is first created. */ ...
- HttpClient使用cookie
import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; ...
- 将MVC中的Controllers、Model和View分别放到单独的项目中
Model: 新建-项目-Windows-类库 MVCTest.Model Controller:新建-项目-Windows-控制台应用程序 MVCTest.Bussiness Views:新建-项目 ...