Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from HansPinckaers/master

Merge latest from head
  • Loading branch information...
commit e642a37eff859876cce7408cc08d67228f2f9e44 2 parents 8e5e23f + 43a7f97
@egoldfarb egoldfarb authored
View
17 class/HPGrowingTextView.h
@@ -62,10 +62,7 @@
BOOL animateHeightChange;
//uitextview properties
- NSObject <HPGrowingTextViewDelegate> *delegate;
- NSString *text;
- UIFont *font;
- UIColor *textColor;
+ NSObject <HPGrowingTextViewDelegate> *__unsafe_unretained delegate;
UITextAlignment textAlignment;
NSRange selectedRange;
BOOL editable;
@@ -79,25 +76,27 @@
@property int maxNumberOfLines;
@property int minNumberOfLines;
@property BOOL animateHeightChange;
-@property (retain) UITextView *internalTextView;
+@property (nonatomic, strong) UITextView *internalTextView;
//uitextview properties
-@property(assign) NSObject<HPGrowingTextViewDelegate> *delegate;
-@property(nonatomic,assign) NSString *text;
-@property(nonatomic,assign) UIFont *font;
-@property(nonatomic,assign) UIColor *textColor;
+@property(unsafe_unretained) NSObject<HPGrowingTextViewDelegate> *delegate;
+@property(nonatomic,strong) NSString *text;
+@property(nonatomic,strong) UIFont *font;
+@property(nonatomic,strong) UIColor *textColor;
@property(nonatomic) UITextAlignment textAlignment; // default is UITextAlignmentLeft
@property(nonatomic) NSRange selectedRange; // only ranges of length 0 are supported
@property(nonatomic,getter=isEditable) BOOL editable;
@property(nonatomic) UIDataDetectorTypes dataDetectorTypes __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_0);
@property (nonatomic) UIReturnKeyType returnKeyType;
@property (assign) UIEdgeInsets contentInset;
+@property(nonatomic) BOOL enablesReturnKeyAutomatically;
//uitextview methods
//need others? use .internalTextView
- (BOOL)becomeFirstResponder;
- (BOOL)resignFirstResponder;
+- (BOOL)isFirstResponder;
- (BOOL)hasText;
- (void)scrollRangeToVisible:(NSRange)range;
View
65 class/HPGrowingTextView.m
@@ -78,8 +78,7 @@ -(void)commonInitialiser
internalTextView.text = @"-";
[self addSubview:internalTextView];
- UIView *internal = (UIView*)[[internalTextView subviews] objectAtIndex:0];
- minHeight = internal.frame.size.height;
+ minHeight = internalTextView.frame.size.height;
minNumberOfLines = 1;
animateHeightChange = YES;
@@ -89,36 +88,24 @@ -(void)commonInitialiser
[self setMaxNumberOfLines:3];
}
--(void)sizeToFit
+-(CGSize)sizeThatFits:(CGSize)size
{
- CGRect r = self.frame;
-
- // check if the text is available in text view or not, if it is available, no need to set it to minimum lenth, it could vary as per the text length
- // fix from Ankit Thakur
- if ([self.text length] > 0) {
- return;
- } else {
- r.size.height = minHeight;
- self.frame = r;
+ if (self.text.length == 0) {
+ size.height = minHeight;
}
+ return size;
}
--(void)setFrame:(CGRect)aframe
+-(void)layoutSubviews
{
- CGRect r = aframe;
+ [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];
-}
-
-- (void)layoutSubviews
-{
- [super layoutSubviews];
- [self performSelector:@selector(textViewDidChange:) withObject:internalTextView];
+ internalTextView.frame = r;
}
-(void)setContentInset:(UIEdgeInsets)inset
@@ -322,12 +309,13 @@ -(BOOL)resignFirstResponder
return [internalTextView resignFirstResponder];
}
-- (void)dealloc {
- [internalTextView release];
- [super dealloc];
+-(BOOL)isFirstResponder
+{
+ return [self.internalTextView isFirstResponder];
}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark UITextView properties
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -374,6 +362,19 @@ -(UIColor*)textColor{
///////////////////////////////////////////////////////////////////////////////////////////////////
+-(void)setBackgroundColor:(UIColor *)backgroundColor
+{
+ [super setBackgroundColor:backgroundColor];
+ internalTextView.backgroundColor = backgroundColor;
+}
+
+-(UIColor*)backgroundColor
+{
+ return internalTextView.backgroundColor;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
-(void)setTextAlignment:(UITextAlignment)aligment
{
internalTextView.textAlignment = aligment;
@@ -422,6 +423,18 @@ -(UIReturnKeyType)returnKeyType
///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)setEnablesReturnKeyAutomatically:(BOOL)enablesReturnKeyAutomatically
+{
+ internalTextView.enablesReturnKeyAutomatically = enablesReturnKeyAutomatically;
+}
+
+- (BOOL)enablesReturnKeyAutomatically
+{
+ return internalTextView.enablesReturnKeyAutomatically;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
-(void)setDataDetectorTypes:(UIDataDetectorTypes)datadetector
{
internalTextView.dataDetectorTypes = datadetector;
View
3  class/HPTextViewInternal.m
@@ -90,9 +90,6 @@ -(void)setContentSize:(CGSize)contentSize
}
-- (void)dealloc {
- [super dealloc];
-}
@end
View
4 example/Classes/GrowingTextViewExampleAppDelegate.h
@@ -34,8 +34,8 @@
GrowingTextViewExampleViewController *viewController;
}
-@property (nonatomic, retain) IBOutlet UIWindow *window;
-@property (nonatomic, retain) GrowingTextViewExampleViewController *viewController;
+@property (nonatomic, strong) IBOutlet UIWindow *window;
+@property (nonatomic, strong) GrowingTextViewExampleViewController *viewController;
@end
View
5 example/Classes/GrowingTextViewExampleAppDelegate.m
@@ -99,11 +99,6 @@ Free up as much memory as possible by purging cached data objects that can be re
}
-- (void)dealloc {
- [viewController release];
- [window release];
- [super dealloc];
-}
@end
View
11 example/Classes/GrowingTextViewExampleViewController.m
@@ -52,7 +52,7 @@ -(id)init
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
- self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
+ self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor colorWithRed:219.0f/255.0f green:226.0f/255.0f blue:237.0f/255.0f alpha:1];
containerView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 40, 320, 40)];
@@ -75,13 +75,13 @@ - (void)loadView {
UIImage *rawEntryBackground = [UIImage imageNamed:@"MessageEntryInputField.png"];
UIImage *entryBackground = [rawEntryBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22];
- UIImageView *entryImageView = [[[UIImageView alloc] initWithImage:entryBackground] autorelease];
+ UIImageView *entryImageView = [[UIImageView alloc] initWithImage:entryBackground];
entryImageView.frame = CGRectMake(5, 0, 248, 40);
entryImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
UIImage *rawBackground = [UIImage imageNamed:@"MessageEntryBackground.png"];
UIImage *background = [rawBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22];
- UIImageView *imageView = [[[UIImageView alloc] initWithImage:background] autorelease];
+ UIImageView *imageView = [[UIImageView alloc] initWithImage:background];
imageView.frame = CGRectMake(0, 0, containerView.frame.size.width, containerView.frame.size.height);
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
@@ -193,10 +193,5 @@ - (void)viewDidUnload {
}
-- (void)dealloc {
- [textView release];
- [containerView release];
- [super dealloc];
-}
@end
View
4 example/GrowingTextViewExample.xcodeproj/project.pbxproj
@@ -230,11 +230,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = GrowingTextViewExample_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "GrowingTextViewExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = GrowingTextViewExample;
@@ -246,9 +248,11 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = GrowingTextViewExample_Prefix.pch;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "GrowingTextViewExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = GrowingTextViewExample;
View
8 example/main.m
@@ -29,8 +29,8 @@
int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
- return retVal;
+ @autoreleasepool {
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ return retVal;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.