Skip to content

red3/HHAssetsCarouselItemView

Repository files navigation

HHAssetsCarouselItemView

Version License Platform

HHAssetsCarouselItemView depends on this repo: HHAttachmentSheetView, click this link to see more detail about how to use HHAttachmentSheetView in your own project.

HHAssetsCarouselItemView enables you to pick a assets in your Photo Library like Messages app.

image

For more details: blog.coderhr.com

Feature

  • Pick a assets in your Photo Library like Messages app.

Requirements

  • Xcode7 or higher
  • iOS 6.0 or higher
  • ARC
  • Objective-C

Installation

CocoaPods

pod "HHAssetsCarouselItemView"

Demo

Open and run the HHAssetsCarouselItemViewDemo.xcworkspace in Xcode to see HHAssetsCarouselItemView in action

Example usage

    NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:5];
    
    HHAssetsCarouselItemView *assetsItem = [[HHAssetsCarouselItemView alloc] initWithCamera:NO selfPortrait:NO forProfilePhoto:NO assetType:TGMediaAssetPhotoType];
    assetsItem.delegate = self;
   
    [items addObject:assetsItem];
    [items addObject:[[HHAttachmentSheetButtonItemView alloc] initWithTitle:@"Choose Photo" pressed:^ {
        NSLog(@"choose photo");
        
    }]];
    [items addObject:[[HHAttachmentSheetButtonItemView alloc] initWithTitle:@"Take Photo" pressed:^ {
        NSLog(@"choose viedo");
        
    }]];
    [items addObject:[[HHAttachmentSheetButtonItemView alloc] initWithTitle:@"Search Photo" pressed:^ {
        NSLog(@"search photo");
        
    }]];
   
    HHAttachmentSheetButtonItemView *cancelItem = [[HHAttachmentSheetButtonItemView alloc] initWithTitle:@"Cancel" pressed:nil];
    cancelItem.bold = YES;
    [items addObject:cancelItem];
    
    _sheetView = [[HHAttachmentSheetView alloc] initWithItems:items];
    [_sheetView showWithAnimate:YES completion:nil];

    __weak ViewController *weakSelf = self;
    __weak HHAttachmentSheetView *weakSheetView = _sheetView;
    __weak HHAssetsCarouselItemView *weakItemView = assetsItem;
    assetsItem.sendPressed = ^ (TGMediaAsset *assets) {
        __strong HHAttachmentSheetView *strongSheetView = weakSheetView;
        __strong HHAssetsCarouselItemView *strongItemView = weakItemView;
        [strongSheetView hideWithAnimate:YES completion:nil];
        TGMediaAsset *asset = [strongItemView.selectionContext.selectedItems firstObject];
        [[TGMediaAssetImageSignals imageForAsset:asset imageType:TGMediaAssetImageTypeLargeThumbnail size:CGSizeMake(200, 200)] startWithNext:^(UIImage *image) {
            if ([image isKindOfClass:[UIImage class]]) {
                weakSelf.imageView.image = image;
            }
        } completed:nil];
    };
	
    

TODO

  • Add more assets type like gif and video.
  • Add CameraPreivew.
  • Add Carthage support.

Update Logs

2015.06.11

  • First commit, support for CocoaPods.

Support

  • If you have any questions, please Issues me, thank you. :)
  • Blog: hirain
  • Buy me a cup of coffee? 👇

License

HHAttachmentSheetView is available under the MIT license. See the LICENSE file for more info.

About

HHAssetsCarouselItemView enables you to pick a assets in your Photo Library like Messages app

Resources

License

Stars

Watchers

Forks

Packages

No packages published