mirror of
https://github.com/zhigang1992/MessagesTableViewController.git
synced 2026-04-23 20:00:07 +08:00
updated demo for message dates
This commit is contained in:
@@ -11,5 +11,6 @@
|
||||
@interface DemoViewController : JSMessagesViewController
|
||||
|
||||
@property (strong, nonatomic) NSMutableArray *messages;
|
||||
@property (strong, nonatomic) NSMutableArray *dates;
|
||||
|
||||
@end
|
||||
@end
|
||||
@@ -19,14 +19,24 @@
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = @"Messages";
|
||||
|
||||
self.dateLabelPolicy = JSMessagesViewDateLabelPolicyEveryThree;
|
||||
|
||||
self.messages = [[NSMutableArray alloc] initWithObjects:
|
||||
@"Testing some messages here.",
|
||||
@"This work is based on Sam Soffes' SSMessagesViewController.",
|
||||
@"This is a complete re-write and refactoring.",
|
||||
@"It's easy to implement. Sound effects and images included. Animations are smooth and messages can be of arbitrary size!",
|
||||
nil];
|
||||
|
||||
self.dates = [[NSMutableArray alloc] initWithObjects:
|
||||
[NSDate distantPast],
|
||||
[NSDate distantPast],
|
||||
[NSDate distantPast],
|
||||
[NSDate distantPast],
|
||||
nil];
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
@@ -46,10 +56,17 @@
|
||||
return [self.messages objectAtIndex:indexPath.row];
|
||||
}
|
||||
|
||||
- (NSDate *)dateForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return [self.dates objectAtIndex:indexPath.row];
|
||||
}
|
||||
|
||||
- (void)sendPressed:(UIButton *)sender withText:(NSString *)text
|
||||
{
|
||||
[self.messages addObject:text];
|
||||
|
||||
[self.dates addObject:[NSDate date]];
|
||||
|
||||
if((self.messages.count - 1) % 2)
|
||||
[JSMessageSoundEffect playMessageSentSound];
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user