Skip to content

binnj/MessagesTableViewController

 
 

Repository files navigation

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.

Note: this is only a messaging UI, not a messaging 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

  1. Subclass JSMessagesViewController
  2. 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";
}
  1. Implement the JSMessagesViewDelegate protocol
  2. Implement the JSMessagesViewDataSource protocol
  3. Implement - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section from the UITableViewDataSource protocol.
  4. Present your subclassed ViewController programatically or via StoryBoards. Your subclass should be the rootViewController of a UINavigationController.
  5. Be a badass programming-motherfucker and read the fucking documentation. (Yes, there's documentation! Seriously!)
  6. See the included demo: JSMessagesDemo.xcworkspace
    • Don't forget to run pod install before opening the demo!

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!

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) {
        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;
        }
    }
    
    if(cell.timestampLabel) {
        cell.timestampLabel.textColor = [UIColor lightGrayColor];
        cell.timestampLabel.shadowOffset = CGSizeZero;
    }
    
    if(cell.subtitleLabel) {
        cell.subtitleLabel.textColor = [UIColor lightGrayColor];
    }
}
  • 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

More tips coming soon! Have your own? Submit a PR!

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 want to do — I know, this is shocking. 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

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

Packages

No packages published

Languages

  • Objective-C 99.3%
  • Ruby 0.7%