Browse files

Revert unwanted changes

This reverts commit c6e86c9.

Conflicts:
	class/HPGrowingTextView.h
	class/HPGrowingTextView.m
  • Loading branch information...
1 parent d35ca39 commit ff78365d8e72b77bc09a6f2f69a2e89dbcc48db5 @egoldfarb egoldfarb committed Oct 31, 2012
Showing with 16 additions and 36 deletions.
  1. +0 −2 class/HPGrowingTextView.h
  2. +16 −34 class/HPGrowingTextView.m
View
2 class/HPGrowingTextView.h
@@ -86,8 +86,6 @@
//uitextview properties
@property(unsafe_unretained) NSObject<HPGrowingTextViewDelegate> *delegate;
-@property(nonatomic,assign) CGFloat minHeight;
-@property(nonatomic,assign) CGFloat maxHeight;
@property(nonatomic,strong) NSString *text;
@property(nonatomic,strong) UIFont *font;
@property(nonatomic,strong) UIColor *textColor;
View
50 class/HPGrowingTextView.m
@@ -33,7 +33,6 @@ @interface HPGrowingTextView(private)
-(void)commonInitialiser;
-(void)resizeTextView:(CGFloat)newSizeH;
-(void)growDidStop;
--(void)sizeToFitMaxHeight;
@end
@implementation HPGrowingTextView
@@ -49,7 +48,6 @@ @implementation HPGrowingTextView
@synthesize animateHeightChange;
@synthesize animationDuration;
@synthesize returnKeyType;
-@synthesize minHeight, maxHeight;
@dynamic placeholder;
@dynamic placeholderColor;
@@ -98,21 +96,24 @@ -(void)commonInitialiser
internalTextView.displayPlaceHolder = YES;
}
--(void)sizeToFit
+-(CGSize)sizeThatFits:(CGSize)size
{
- [self sizeToFitMaxHeight];
+ if (self.text.length == 0) {
+ size.height = minHeight;
+ }
+ return size;
}
--(void)setFrame:(CGRect)aframe
+-(void)layoutSubviews
{
- CGRect r = aframe;
- r.origin.y = 0;
- r.origin.x = contentInset.left;
+ [super layoutSubviews];
+
+ CGRect r = self.bounds;
+ r.origin.y = 0;
+ r.origin.x = contentInset.left;
r.size.width -= contentInset.left + contentInset.right;
-
- internalTextView.frame = r;
-
- [super setFrame:aframe];
+
+ internalTextView.frame = r;
}
-(void)setContentInset:(UIEdgeInsets)inset
@@ -197,12 +198,6 @@ - (NSString *)placeholder
{
return internalTextView.placeholder;
}
-- (void)setMinHeight:(CGFloat)height
-{
- minHeight = height;
-
- [self sizeToFit];
-}
- (void)setPlaceholder:(NSString *)placeholder
{
@@ -236,15 +231,8 @@ - (void)refreshPlaceholder
}
}
-- (void)setMaxHeight:(CGFloat)height
-{
- maxHeight = height;
-
- [self sizeToFit];
-}
-
-- (void) sizeToFitMaxHeight
-{
+- (void)textViewDidChange:(UITextView *)textView
+{
//size of content, so we can set the frame of self
CGFloat newSizeH = internalTextView.contentSize.height;
if(newSizeH < minHeight || !internalTextView.hasText) newSizeH = minHeight; //not smalles than minHeight
@@ -267,7 +255,7 @@ - (void) sizeToFitMaxHeight
if ([UIView resolveClassMethod:@selector(animateWithDuration:animations:)]) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
[UIView animateWithDuration:animationDuration
- delay:0
+ delay:0
options:(UIViewAnimationOptionAllowUserInteraction|
UIViewAnimationOptionBeginFromCurrentState)
animations:^(void) {
@@ -315,12 +303,6 @@ - (void) sizeToFitMaxHeight
internalTextView.scrollEnabled = NO;
}
}
-}
-
-
-- (void)textViewDidChange:(UITextView *)textView
-{
- [self sizeToFitMaxHeight];
// Display (or not) the placeholder string
[self refreshPlaceholder];

0 comments on commit ff78365

Please sign in to comment.