/MessagesTableViewController

A messages UI for iPhone and iPad

Primary LanguageObjective-COtherNOASSERTION

JSMessagesViewController

Build Status Version Status license MIT

A messages UI for iPhone and iPad.

JSMessagesViewController is a UIViewController subclass that is very similar to the iOS Messages app.

Messages Screenshot 1     Messages Screenshot 2

See more screenshots in the Screenshots/ directory.

Features

  • Highly customizable
  • Arbitrary message sizes
  • Copy & paste messages
  • Support for group messages
  • Data detectors (recognizes phone numbers, links, dates, etc.)
  • Timestamps
  • Avatars
  • Subtitles
  • Lots of bubble styles, or use your own!
  • Swipe down to hide keyboard
  • Dynamically resizes input text view as you type
  • Smooth animations
  • Automatically enables/disables send button (if text view is empty or not)
  • Send/Receive sound effects
  • Storyboards support (if that's how you roll)
  • Universal for iPhone and iPad

Requirements

Installation

pod 'JSMessagesViewController'

From source

  • Drag the JSMessagesViewController/ folder to your project
  • Download JSQSystemSoundPlayer and follow its install instructions
  • Add the QuartzCore.framework to your project

Too cool for ARC?

  • Add the -fobjc-arc compiler flag to all source files in your project in Target Settings > Build Phases > Compile Sources.

Getting Started

Setup your model

Your model objects should conform to the JSMessageData protocol. However, you may use the provided JSMessage class for your model objects if you wish.

Setup your view controller

  1. Subclass JSMessagesViewController
  2. Conform to the protocols <JSMessagesViewDelegate, JSMessagesViewDataSource>
  3. Implement the JSMessagesViewDelegate protocol
  4. Implement the JSMessagesViewDataSource protocol
  5. Implement tableView: numberOfRowsInSection: from the UITableViewDataSource protocol.
  6. Setup your viewDidLoad like the following:
- (void)viewDidLoad
{
    self.delegate = self;
    self.dataSource = self;
    [super viewDidLoad];
    
    [[JSBubbleView appearance] setFont:/* your font for the message bubbles */];

    self.title = @"Your view controller title";
    
    self.messageInputView.textView.placeHolder = @"Your placeholder text";

    self.sender = @"Username of sender";
}

Present your view controller

  1. Present your subclassed view controller programatically or via StoryBoards. Your subclass should be the rootViewController of a UINavigationController, or pushed on an existing navigation stack.

  2. You may want to show the most recent message when presenting your view: (this is no longer default behavior)

// Scroll to the most recent message before view appears
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self scrollToBottomAnimated:NO];
}

Questions?

  1. Be a badass programming-motherfucker and read the fucking documentation. Yes, there's fucking documentation! And it is fucking kept up-to-date. How fucking sweet is that? Pretty fucking sweet.
  2. See the included demo: JSMessagesDemo.xcworkspace. Don't forget to run pod install before opening!
  3. Still need help? That's ok! Just open a new issue with your question, and add the question label.
  4. Please do not email me your question if you need help. But I really want to email you. Why can't I?
    • Opening an issue is better for you and the community, because it provides better transparency.
    • I'm often busy and may not reply in a timely manor.
    • People using this library and watching this repo may be able to answer your question sooner.
    • Someone else likely has a similar question and also needs an answer.
    • Users of this library can search the issues for previously asked questions.

Documentation

Documentation is available here via CocoaDocs. Thanks @CocoaDocs!

Donate

Support the developement of this free, open-source control! via Square Cash.

Send $1 Just saying thanks!

Send $5 This control is great!

Send $10 This totally saved me time!

Send $25 I want new features!

Send $50 I love this project!

Customization

  • You can customize almost any property of a cell by implementing the optional delegate method configureCell: atIndexPath:
- (void)configureCell:(JSBubbleMessageCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    if ([cell messageType] == JSBubbleMessageTypeOutgoing) {

        // Customize any UITextView properties
        cell.bubbleView.textView.textColor = [UIColor whiteColor];
    
        if ([cell.bubbleView.textView respondsToSelector:@selector(linkTextAttributes)]) {
            NSMutableDictionary *attrs = [cell.bubbleView.textView.linkTextAttributes mutableCopy];
            [attrs setValue:[UIColor blueColor] forKey:UITextAttributeTextColor];
            
            cell.bubbleView.textView.linkTextAttributes = attrs;
        }
    }
    
    // Customize any UILabel properties for timestamps or subtitles
    if (cell.timestampLabel) {
        cell.timestampLabel.textColor = [UIColor lightGrayColor];
        cell.timestampLabel.shadowOffset = CGSizeZero;
    }
    
    if (cell.subtitleLabel) {
        cell.subtitleLabel.textColor = [UIColor lightGrayColor];
    }

    // Enable data detectors
    cell.bubbleView.textView.dataDetectorTypes = UIDataDetectorTypeAll;
}
  • Set the font for your messages bubbles via UIAppearance
[[JSBubbleView appearance] setFont:[UIFont systemFontOfSize:16.0f]];
  • Customize your message bubbles with JSBubbleImageViewFactory

  • Customize your avatars with JSAvatarImageFactory

How To Contribute

Please follow these sweet contribution guidelines.

Credits

Created by @jesse_squires, a programming-motherfucker.

Assets extracted using @0xced / iOS-Artwork-Extractor.

Originally inspired by @soffes / SSMessagingViewController.

Many thanks to the contributors of this project.

Square message bubbles designed by @michaelschultz.

About

I initially developed this control to use in Hemoglobe for private messages between users.

As it turns out, messaging is a popular thing that iOS devs and users want. Thus, I am supporting this project in my free time and have added features way beyond what Hemoglobe ever needed.

Check out my work at Hexed Bits.

Apps Using This Control

Hemoglobe

Loopse

Oxwall Messenger

FourChat

Quick Text Message

Libraries for developers

Contact me to have your app listed here.

Related Projects

SSMessagingViewController

AcaniChat

UIBubbleTableView

SPHChatBubble

You are free to use this as you please. No attribution necessary, but much appreciated.

Copyright © 2013 Jesse Squires

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge