From e539bdfe4c81fb56fc1974596f1795e061b52663 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 3 Nov 2013 01:36:13 +0400 Subject: Detect links --- Juick/MasterViewController.m | 2 -- Juick/MessageCell.h | 7 ++++--- Juick/MessageCell.m | 10 ++++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'Juick') diff --git a/Juick/MasterViewController.m b/Juick/MasterViewController.m index bd75f82..74b4fdc 100644 --- a/Juick/MasterViewController.m +++ b/Juick/MasterViewController.m @@ -6,8 +6,6 @@ // Copyright (c) 2013 com.juick. All rights reserved. // -#import "SWRevealViewController.h" - #import "MasterViewController.h" #import "MessageCell.h" diff --git a/Juick/MessageCell.h b/Juick/MessageCell.h index 6f93048..299c3b3 100644 --- a/Juick/MessageCell.h +++ b/Juick/MessageCell.h @@ -7,14 +7,15 @@ // #import +#import "TTTAttributedLabel.h" #define kLabelHorizontalInsets 20.0f -@interface MessageCell : UITableViewCell +@interface MessageCell : UITableViewCell -@property (strong, nonatomic) IBOutlet UILabel *titleLabel; -@property (strong, nonatomic) IBOutlet UILabel *bodyLabel; +@property (strong, nonatomic) IBOutlet TTTAttributedLabel *titleLabel; +@property (strong, nonatomic) IBOutlet TTTAttributedLabel *bodyLabel; - (void)updateFonts; diff --git a/Juick/MessageCell.m b/Juick/MessageCell.m index a8b2522..dc698b3 100644 --- a/Juick/MessageCell.m +++ b/Juick/MessageCell.m @@ -20,7 +20,7 @@ { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { - self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + self.titleLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero]; [self.titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; [self.titleLabel setLineBreakMode:NSLineBreakByTruncatingTail]; [self.titleLabel setNumberOfLines:1]; @@ -28,7 +28,9 @@ [self.titleLabel setTextColor:[UIColor blackColor]]; [self.titleLabel setBackgroundColor:[UIColor clearColor]]; - self.bodyLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + self.bodyLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero]; + self.bodyLabel.dataDetectorTypes = NSTextCheckingTypeLink; + self.bodyLabel.delegate = self; [self.bodyLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; [self.bodyLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical]; [self.bodyLabel setLineBreakMode:NSLineBreakByTruncatingTail]; @@ -131,4 +133,8 @@ self.bodyLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; } +- (void) attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url { + [[UIApplication sharedApplication] openURL:url]; +} + @end -- cgit v1.2.3