diff --git a/JSMessagesTableViewController/JSMessageInputView.m b/JSMessagesTableViewController/JSMessageInputView.m index d092761c2..69b52c4a0 100644 --- a/JSMessagesTableViewController/JSMessageInputView.m +++ b/JSMessagesTableViewController/JSMessageInputView.m @@ -66,7 +66,13 @@ - (id)initWithFrame:(CGRect)frame - (void)setup { - self.image = [[UIImage imageNamed:@"input-bar"] resizableImageWithCapInsets:UIEdgeInsetsMake(19.0f, 3.0f, 19.0f, 3.0f)]; + UIImage *barImage = [UIImage imageNamed:@"input-bar"]; + if ([barImage respondsToSelector:@selector(resizableImageWithCapInsets:)]) { + barImage = [barImage resizableImageWithCapInsets:UIEdgeInsetsMake(19.0f, 3.0f, 19.0f, 3.0f)]; + } else { + barImage = [barImage stretchableImageWithLeftCapWidth:3.0f topCapHeight:19.0f]; + } + self.image = barImage; self.backgroundColor = [UIColor whiteColor]; self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin); self.opaque = YES; @@ -99,7 +105,13 @@ - (void)setupTextView 0.0f, self.textView.frame.size.width + 2.0f, self.frame.size.height)]; - inputFieldBack.image = [[UIImage imageNamed:@"input-field"] resizableImageWithCapInsets:UIEdgeInsetsMake(20.0f, 12.0f, 18.0f, 18.0f)]; + UIImage *backImage = [UIImage imageNamed:@"input-field"]; + if ([backImage respondsToSelector:@selector(resizableImageWithCapInsets:)]) { + backImage = [backImage resizableImageWithCapInsets:UIEdgeInsetsMake(20.0f, 12.0f, 18.0f, 18.0f)]; + } else { + backImage = [backImage stretchableImageWithLeftCapWidth:12.0f topCapHeight:20.0f]; + } + inputFieldBack.image = backImage; inputFieldBack.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); inputFieldBack.backgroundColor = [UIColor clearColor]; [self addSubview:inputFieldBack]; @@ -134,6 +146,7 @@ - (void)adjustTextViewHeightBy:(CGFloat)changeInHeight 0.0f); self.textView.scrollEnabled = (numLines >= 4); + [self.textView scrollRangeToVisible:self.textView.selectedRange]; } + (CGFloat)textViewLineHeight @@ -151,4 +164,4 @@ + (CGFloat)maxHeight return ([JSMessageInputView maxLines] + 1.0f) * [JSMessageInputView textViewLineHeight]; } -@end \ No newline at end of file +@end diff --git a/JSMessagesTableViewController/JSMessagesViewController.h b/JSMessagesTableViewController/JSMessagesViewController.h index 452838087..de9ff0a43 100644 --- a/JSMessagesTableViewController/JSMessagesViewController.h +++ b/JSMessagesTableViewController/JSMessagesViewController.h @@ -48,7 +48,15 @@ typedef enum { JSMessagesViewTimestampPolicyCustom } JSMessagesViewTimestampPolicy; - +#ifndef JSMESSAGES_WEAK +#if __has_feature(objc_arc_weak) +#define JSMESSAGES_WEAK weak +#elif __has_feature(objc_arc) +#define JSMESSAGES_WEAK unsafe_unretained +#else +#define JSMESSAGES_WEAK assign +#endif +#endif @protocol JSMessagesViewDelegate @required @@ -70,8 +78,8 @@ typedef enum { @interface JSMessagesViewController : UIViewController -@property (weak, nonatomic) id delegate; -@property (weak, nonatomic) id dataSource; +@property (JSMESSAGES_WEAK, nonatomic) id delegate; +@property (JSMESSAGES_WEAK, nonatomic) id dataSource; @property (strong, nonatomic) UITableView *tableView; @property (strong, nonatomic) JSMessageInputView *inputView; @property (assign, nonatomic) CGFloat previousTextViewContentHeight; @@ -94,4 +102,4 @@ typedef enum { - (void)handleWillHideKeyboard:(NSNotification *)notification; - (void)keyboardWillShowHide:(NSNotification *)notification; -@end \ No newline at end of file +@end diff --git a/JSMessagesTableViewController/UIButton+JSMessagesView.m b/JSMessagesTableViewController/UIButton+JSMessagesView.m index 3aacfa379..e7ea97b2b 100644 --- a/JSMessagesTableViewController/UIButton+JSMessagesView.m +++ b/JSMessagesTableViewController/UIButton+JSMessagesView.m @@ -16,8 +16,19 @@ + (UIButton *)defaultSendButton sendButton.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin); UIEdgeInsets insets = UIEdgeInsetsMake(0.0f, 13.0f, 0.0f, 13.0f); - UIImage *sendBack = [[UIImage imageNamed:@"send"] resizableImageWithCapInsets:insets]; - UIImage *sendBackHighLighted = [[UIImage imageNamed:@"send-highlighted"] resizableImageWithCapInsets:insets]; + + UIImage *sendBack = [UIImage imageNamed:@"send"]; + if ([sendBack respondsToSelector:@selector(resizableImageWithCapInsets:)]) { + sendBack = [sendBack resizableImageWithCapInsets:insets]; + } else { + sendBack = [sendBack stretchableImageWithLeftCapWidth:insets.left topCapHeight:insets.top]; + } + UIImage *sendBackHighLighted = [UIImage imageNamed:@"send-highlighted"]; + if ([sendBackHighLighted respondsToSelector:@selector(resizableImageWithCapInsets:)]) { + sendBackHighLighted = [sendBackHighLighted resizableImageWithCapInsets:insets]; + } else { + sendBackHighLighted = [sendBack stretchableImageWithLeftCapWidth:insets.left topCapHeight:insets.top]; + } [sendButton setBackgroundImage:sendBack forState:UIControlStateNormal]; [sendButton setBackgroundImage:sendBack forState:UIControlStateDisabled]; [sendButton setBackgroundImage:sendBackHighLighted forState:UIControlStateHighlighted]; @@ -40,4 +51,4 @@ + (UIButton *)defaultSendButton return sendButton; } -@end \ No newline at end of file +@end diff --git a/JSMessagesViewController.podspec b/JSMessagesViewController.podspec index fd0c53e80..3adb88fce 100644 --- a/JSMessagesViewController.podspec +++ b/JSMessagesViewController.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| s.license = 'MIT License' s.author = { "Jesse Squires" => "jesse.d.squires@gmail.com" } s.source = { :git => "https://github.com/jessesquires/MessagesTableViewController.git", :tag => s.version.to_s } - s.platform = :ios, '5.0' + s.platform = :ios, '4.2' s.source_files = 'JSMessagesTableViewController' s.resources = "JSMessagesTableViewController/Resources/**/*.*" s.frameworks = 'AudioToolbox'