• Stars
    star
    296
  • Rank 140,464 (Top 3 %)
  • Language
    Objective-C
  • Created about 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ChatMessageTableViewController is like iMessage app. support text && image .

ChatMessageTableViewController

A messages UI for iPhone. ChatMessageTableViewController is like iMessage app. support text && image .

Messages Screenshot 1

Messages Screenshot 2

This messages tableview controller is very similar to the one in the iOS Messages app. Note, this is only a messaging UI, not a messaging app. This is intended to be used in an existing app where you have (or are developing) a messaging system and need a user interface for it.

See more screenshots in the Screenshots/ directory. (Surprise!)

About

This is based on work by @soffes SSMessagingViewController.

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

Square message bubbles designed by @michaelschultz.

Features

  • Up-to-date for iOS 6.0 and ARC (iOS 5.0+ required)
  • Universal for iPhone
  • Allows arbitrary message (and bubble) sizes
  • Copy & paste text message && Save image message
  • Timestamp options
  • Swipe/pull down to hide keyboard
  • Dynamically resizes input text view as you type
  • Smooth hiding/showing keyboard animations with NSNotification
  • Automatically enables/disables send button if text view is empty or not
  • Smooth send animations
  • Send/Receive sound effects
  • Various bubble styles

From source

  • Drag the JSMessagesTableViewController/ folder to your project.
  • Add the AudioToolbox.framework to your project, if you want to use the sound effects

How To Use

#####Subclass JSMessagesViewController

  • In - (void)viewDidLoad
    • Set your view controller as the delegate and datasource
    • Set your view controller title

#####Implement the JSMessagesViewDelegate protocol

- (void)sendPressed:(UIButton *)sender withText:(NSString *)text
  • Hook into your own backend here
  • Call [self finishSend] at the end of this method to animate and reset the text input view
  • Optionally play sound effects
    • For outgoing messages [JSMessageSoundEffect playMessageSentSound]
    • For incoming messages [JSMessageSoundEffect playMessageReceivedSound]
- (JSBubbleMessageType)messageTypeForRowAtIndexPath:(NSIndexPath *)indexPath
  • The type of bubble for this row, options are:

    • JSBubbleMessageTypeIncoming
    • JSBubbleMessageTypeOutgoing
  • The type of Message for this row, options are:

    • JSBubbleMediaTypeText
    • JSBubbleMediaTypeImage
- (JSBubbleMediaType)messageMediaTypeForRowAtIndexPath:(NSIndexPath *)indexPath
  • The style of the bubble for this row, options are:
    • JSBubbleMessageStyleDefault
    • JSBubbleMessageStyleSquare
    • JSBubbleMessageStyleDefaultGreen
- (JSMessagesViewTimestampPolicy)timestampPolicy
  • How/when to display timestamps for messages, options are:
    • JSMessagesViewTimestampPolicyAll
    • JSMessagesViewTimestampPolicyAlternating
    • JSMessagesViewTimestampPolicyEveryThree
    • JSMessagesViewTimestampPolicyEveryFive
    • JSMessagesViewTimestampPolicyCustom
- (JSMessagesViewAvatarPolicy)avatarPolicy
  • How/when to display avatars, options are:
    • JSMessagesViewAvatarPolicyIncomingOnly
    • JSMessagesViewAvatarPolicyBoth
    • JSMessagesViewAvatarPolicyNone
- (JSAvatarStyle)avatarStyle
- (BOOL)hasTimestampForRowAtIndexPath:(NSIndexPath *)indexPath
  • Returns if this row should display a timestamp or not
  • Required only if using JSMessagesViewTimestampPolicyCustom

#####Implement the JSMessagesViewDataSource protocol

- (NSString *)textForRowAtIndexPath:(NSIndexPath *)indexPath
  • The text to be displayed for this row
- (NSDate *)timestampForRowAtIndexPath:(NSIndexPath *)indexPath
  • The timestamp to be displayed above this row
- (UIImage *)avatarImageForIncomingMessage
  • The avatar image for incoming messages
- (UIImage *)avatarImageForOutgoingMessage
  • The avatar image for outgoing messages

#####Implement the table view data source method that you should be familiar with

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

#####Customize

  • For custom background color, use - (void)setBackgroundColor:(UIColor *)color
  • For custom send button, override - (UIButton *)sendButton
Notes
  • You may present view programmatically, or use Storyboards
  • Your JSMessagesViewController subclass must be presented in a UINavigationController
Demo projects included
  • MessagesDemo.xcodeproj for example of programmatic presentation
  • MessagesDemoStoryboards/MessagesDemoSB.xcodeproj for example of use with Storyboards

Apps Using This Control

Hemoglobe

FourChat

Libraries for developers

jessesquires 's MessagesTableViewController

Contact me to have your app listed here.

Related Projects

SSMessagingViewController

AcaniChat

MIT License

You are free to use this as you please. No attribution necessary. If you use this, please tell me about it!

Copyright © 2013 Robin

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.

More Repositories

1

AnimatedPaths

Animating the drawing of a CGPath with CAShapeLayer.strokeEnd
Swift
34
star
2

CoreML-Practice-with-SwiftUI

CoreML Practice with SwiftUI Demos. FCRN-DepthPrediction、MNISTClassifier、ImageClassifier、Object Detection and more is comming on.
Swift
15
star
3

Data-Analysis-and-Data-Operation-with-Python

《Python数据分析与数据化运营》读书笔记
Jupyter Notebook
8
star
4

iOS-zstd

iOS-Zstandard - Fast real-time compression algorithm http://www.zstd.net
C
6
star
5

Card-List-with-SwiftUI

该代码示例展示如何使用SwiftUI搭建移动端基础的卡片式内容展示列表。
Swift
6
star
6

CaptureImageToGif

CaptureImageToGif
Objective-C
5
star
7

turicreate-tutorial

Turi Create Tutorial for Machine Learning Researchers
Swift
5
star
8

RCDeviceLockEvent

Tracking the Device Lock event and so so
Objective-C
2
star
9

SleepAnalysis

The SleepAnalysis Demo
Swift
2
star
10

ImageFitler

ImageFitlerDemo used ColorMatrix
Objective-C
2
star
11

NetManager

项目基础组件功能封装
Objective-C
1
star
12

rollout.io-ios-swift_beta

Shell
1
star
13

Swift-Extension

Swift
1
star
14

Learn-Python-The-Hard-Way

Learn Python from Zero to Zero
Python
1
star
15

ThreadMonitor

一个捕捉界面卡顿时,MainThread中响应超时堆栈信息的工具。
Objective-C
1
star
16

RequestDemoSwift

HttpRequestDemo with Swift lang
Swift
1
star
17

MultipleTappableLinksLabel

The `UILabel` can mutiple colors and links.
Swift
1
star
18

ICU-Text-Transform

Swift
1
star
19

SelfSizingCellTemplete

SelfSizingCell Templete
Swift
1
star
20

Hacking-with-Swift

This repository is learning HackingWithSwift Demos.
Swift
1
star
21

XZ-Utils-for-iOS-and-OSX

XZ Utils build shell for iOS && OS X
Objective-C
1
star
22

zycslog.github.io

HTML
1
star
23

opencv-examples

Objective-C
1
star
24

Linear-algebra-study-notes

Linear algebra study notes
Jupyter Notebook
1
star
25

RBPlacehoderTextView

Placeholder text in UITextView
Objective-C
1
star
26

ImageDetector-iOS

Swift
1
star
27

CommonThirdPart

项目中常用的第三方库整理
1
star