Latest 1.1.9
Homepage https://github.com/Healthjoy-iOS/IMessageAttachment
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation, UIKit, AVFoundation, Photos
Authors

A simple iOS photo attachment control with feed of photos from library and camera streaming for capture photo.

IMessageAttachment inspired and copied from iMessage attachment control.
Attachment control from iMessage:
Alt    Alt

IMessageAttachment example:
    
Alt    Alt   

IMessageAttachment implementetion in a project:
 
Alt    Alt

Works on iOS 8+.

Usage

IMessageAttachment is just a UICollectionView with controls, designed for use with keyboard like in iMessage application. Setup IMessageCollectionView in your viewController, set the delegate (which must conform to IMessageViewControllerDelegate) and implement the 1 required delegate methods to provide UIImage from controls.

See the code snippet below for an example of how to implement the IMessageAttachment control. There is also a simple demo app within the project.

// define IMessageCollectionView
@property (nonatomic, weak) IBOutlet IMessageCollectionView *attachmentCollectionView;
@property (nonatomic, weak) IBOutlet NSLayoutConstraint *attachmentCollectionViewHeightConstraint;

// set delegate in viewDidLoad()
self.attachmentCollectionView.VCDelegate = self;

// define IMessageViewControllerProtocol
- (void)pickedAttachmentImage:(UIImage *)attachmentImage {
    [self.attachmentContent addObject:attachmentImage];
}

You can update attachmentCollectionView’s height automatically by take keyboard’s height. And it’s required thing if you wanna work like iMessage attachment control with keyboard.

// setup notification
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(updateAttachmentHeight:)
                                             name:UIKeyboardDidShowNotification
                                           object:nil];

// update attachmentCollectionView's height
- (void)updateAttachmentHeight:(NSNotification*)notification {
    NSDictionary* keyboardInfo = [notification userInfo];
    NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey];
    CGFloat height = [keyboardFrameBegin CGRectValue].size.height;

    self.attachmentCollectionViewHeightConstraint.constant = height;
    [self.attachmentCollectionView updateCollectionViewHeight:height];
}

That’s all.

Installation

IMessageAttachment is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "IMessageAttachment"

Or you can copy IMessageAttachment folder to your project.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Then import the IMessageCollectionView into your source files:

#import "IMessageCollectionView.h"

Author

Mark Prutskiy, [email protected] HealthJoy

License

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

Latest podspec

{
    "name": "IMessageAttachment",
    "version": "1.1.9",
    "license": "MIT",
    "summary": "Photo attachment control from iMessage app",
    "homepage": "https://github.com/Healthjoy-iOS/IMessageAttachment",
    "authors": {
        "Mark Prutskiy": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Healthjoy-iOS/IMessageAttachment.git",
        "tag": "1.1.9"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "IMessageAttachment/Classes/**/*",
    "ios": {
        "resource_bundles": {
            "IMessageAttachment": [
                "IMessageAttachment/Resources/*.png"
            ]
        }
    },
    "requires_arc": true,
    "frameworks": [
        "Foundation",
        "UIKit",
        "AVFoundation",
        "Photos"
    ]
}

Pin It on Pinterest

Share This