IMessageAttachment 1.1.23

IMessageAttachment 1.1.23

测试测试结果
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2018年3月

Mark Prutskiy 维护。



  • Mark Prutskiy

一款简单的 iOS 照片附件控件,通过库和相机流获取照片进行拍摄。

IMessageAttachment 吁丹吸金于 iMessage 附件控件。
iMessage 附件控件
Alt    Alt
IMessageAttachment 示例
     Alt    Alt   
在项目中实现 IMessageAttachment
  Alt    Alt

在 iOS 8+ 上运行。

使用方法

IMessageAttachment 仅是一个带控件的 UICollectionView,旨在与 iMessage 应用程序中的键盘一起使用。在 viewController 中设置 IMessageCollectionView,设置代理(必须遵守 IMessageViewControllerDelegate),并实现 1 个必需的代理方法以提供来自控件的 UIImage

下面是一个示例代码片段,说明如何实现 IMessageAttachment 控件。项目中还有一个简单的演示应用程序。

// 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];
}

可以通过获取键盘的高度来自动更新 attachmentCollectionView 的高度。如果你想要像 iMessage 附件控制那样操作键盘,这是一个必需的操作。

// 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];
}

这就是全部内容。

安装

IMessageAttachment 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile 中

pod "IMessageAttachment"

或者,您可以复制 IMessageAttachment 文件夹到您的项目中。

用法

要运行示例项目,请克隆仓库,然后在 Example 目录中首先运行 pod install

然后,将 IMessageCollectionView 导入到您的源文件中

#import "IMessageCollectionView.h"

作者

马克·普鲁茨基,[email protected] HealthJoy

许可证

IMessageAttachment 可在 MIT 许可下使用。有关更多信息,请参阅 LICENSE 文件。