SOMessaging 1.0.0

SOMessaging 1.0.0

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

[arturdev] 维护。



  • 作者:
  • Artur Mkrtchyan

arturdev


点击截图查看视频演示

这是一个简单易用的库,可以轻松创建具有顺畅动画的消息应用程序。
可自定义内容
• 所有内容!!

要求

Xcode 5
iOS 7.0+
ARC

用法

SOMessaging 文件夹复制到您的项目中。

链接到 MediaPlayer.frameworkQuartzCore.framework

创建 SOMessagingViewController 的子类

重写 SOMessagingDataSource 协议的以下所需方法

- (NSMutableArray *)messages
{
    //return array of SOMessage objects
}

- (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)index
{
    SOMessage *message = self.dataSource[index];

    // Customize balloon as you wish
    if (message.fromMe) {

    } else {

    }
}

重写 SOMessagingDelegate 协议的以下所需方法

- (void)didSelectMedia:(NSData *)media inMessageCell:(SOMessageCell *)cell
{
    // Show selected media in fullscreen
    [super didSelectMedia:media inMessageCell:cell];
}

- (void)messageInputView:(SOMessageInputView *)inputView didSendMessage:(NSString *)message
{
    if (![[message stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length]) {
        return;
    }

    SOMessage *msg = [[SOMessage alloc] init];
    msg.text = message;
    msg.fromMe = YES;

    [self sendMessage:msg];
}

- (void)messageInputViewDidSelectMediaButton:(SOMessageInputView *)inputView
{
    // Take a photo/video or choose from gallery
}

您已经完成!

自定义

在 Demo 项目中,您可以找到如何使用此库和如何进行自定义的信息。

查看 SOMessagingDataSource 协议

/**
 * Array of SOMessage objects.
 */
- (NSMutableArray *)messages;

/**
 * Override this method if you want to customize cell that will be shown.
 * This method calls after cell default adjustment on every reuse time
 */
- (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)index;

@optional

/**
 * Default implementation of this method is calculating height of the cell for message at given index.
 */
- (CGFloat)heightForMessageForIndex:(NSInteger)index;

/**
 * Messages will be grouped by returned time interval (in seconds).
 * return 0 if you don't want grouping.
 */
- (NSTimeInterval)intervalForMessagesGrouping;

/**
 * Return resizable image for sending balloon background image
 */
- (UIImage *)balloonImageForSending;

/**
 * Return resizable image for receiving balloon background image
 */
- (UIImage *)balloonImageForReceiving;

/**
 * Maximum width of message
 */
- (CGFloat)messageMaxWidth;

/**
 * Minimum height of balloon
 */
- (CGFloat)balloonMinHeight;

/**
 * Minimum width of balloon
 */
- (CGFloat)balloonMinWidth;

/**
 * Font of message
 */
- (UIFont *)messageFont;

/**
 * Size of photo or video thumbnail imageView
 */
- (CGSize)mediaThumbnailSize;

/**
 * Size user's imageview
 */
- (CGSize)userImageSize;