ARSwipeToSelectPickerController 版本 0.3

ARSwipeToSelectPickerController 版本 0.3

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

未知的 维护。




  • 作者:
  • Andrew Ng 和 Ray Tsaihong

animatedgif

一个类似 UIImagePickerController 的资产选择器,它利用 ARMultiSelectGestureRecognizer 进行滑动选择

添加到项目

ARSwipeToSelectPickerController 添加到您的项目最简单的方法是通过 CocoaPods

pod 'ARSwipeToSelectPickerController'

或者,您可以将 Classes/ 目录中的所有文件复制到您的项目中。确保已勾选“将项目复制到目标文件夹”。

使用

  1. 导入头文件:#import "ARSwipeToSelectPickerController.h"
  2. 符合 ARSwipeToSelectPickerControllerDelegate 协议,实现其 代理方法
  3. 实例化控制器
ARSwipeToSelectPickerController *picker = [[ARSwipeToSelectPickerController alloc] initWithDelegate:self];
[self.navigationController pushViewController:picker animated:YES];

您还可以先将其嵌入到 UINavigationController 中以模式显示选择器

ARSwipeToSelectPickerController *picker = [[ARSwipeToSelectPickerController alloc] initWithDelegate:self];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:picker];
[self presentViewController:nav animated:YES completion:nil];

代理方法

#pragma mark - ARSwipeToSelectPickerControllerDelegate methods

- (void) swipeToSelectPickerControllerDidCancel:(ARSwipeToSelectPickerController *)sender
{
    // use popViewControllerAnimated if using navigation controller for viewcontroller stack
    //[self.navigationController popViewControllerAnimated:YES];

    // use dismissViewControllerAnimated if not using a navigation controller
    //[self dismissViewControllerAnimated:YES completion:nil];
}

- (void) swipeToSelectPickerController:(ARSwipeToSelectPickerController *)sender didFinishPickingMediaWithAssets:(NSArray *)assets
{
    // Use MWPhotoBrowser to show the selected photos
    [self dismissViewControllerAnimated:NO completion:^{
        NSMutableArray *tmpArray = [[NSMutableArray alloc] initWithCapacity:[assets count]];
        [assets enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            UIImage *image = [UIImage imageWithCGImage:[[((ALAsset *) obj) defaultRepresentation] fullScreenImage]];
            [tmpArray addObject:[MWPhoto photoWithImage:image]];
        }];
        self.photos = tmpArray;
        MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
        browser.displayActionButton = NO;
        [browser setInitialPageIndex:0];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self presentViewController:browser animated:YES completion:nil];
        });
    }];
}

或者如果您在 UINavigationController 栈中,可以执行以下操作来关闭选择器控制器

[self.navigationController popToViewController:self animated:YES];

演示

您可以在 演示文件夹 找到一个令人印象深刻的演示!

联合创作者

Bitdeli Badge