Permalink
Browse files

Initial import from http://www.hanspinckaers.com/multi-line-uitextvie…

…w-similar-to-sms (MIT license)
  • Loading branch information...
0 parents commit 3dc2fa4cb16a6a63861ea65b180b08e7c48e08cc @hboon committed Jul 20, 2011
14 .gitignore
@@ -0,0 +1,14 @@
+# OS X noise
+.DS_Store
+
+# vi swap files
+*.swp
+
+# Xcode noise
+build/
+*.pbxuser
+*.mode1v3
+config
+
+# Other tools
+tags
21 LICENSE.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2011 Hans Pinckaers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
99 class/HPGrowingTextView.h
@@ -0,0 +1,99 @@
+//
+// HPTextView.h
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <UIKit/UIKit.h>
+
+@class HPGrowingTextView;
+@class HPTextViewInternal;
+
+@protocol HPGrowingTextViewDelegate
+
+@optional
+- (BOOL)growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView;
+- (BOOL)growingTextViewShouldEndEditing:(HPGrowingTextView *)growingTextView;
+
+- (void)growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView;
+- (void)growingTextViewDidEndEditing:(HPGrowingTextView *)growingTextView;
+
+- (BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
+- (void)growingTextViewDidChange:(HPGrowingTextView *)growingTextView;
+
+- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height;
+- (void)growingTextView:(HPGrowingTextView *)growingTextView didChangeHeight:(float)height;
+
+- (void)growingTextViewDidChangeSelection:(HPGrowingTextView *)growingTextView;
+- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView;
+@end
+
+@interface HPGrowingTextView : UIView <UITextViewDelegate> {
+ HPTextViewInternal *internalTextView;
+
+ int minHeight;
+ int maxHeight;
+
+ //class properties
+ int maxNumberOfLines;
+ int minNumberOfLines;
+
+ BOOL animateHeightChange;
+
+ //uitextview properties
+ NSObject <HPGrowingTextViewDelegate> *delegate;
+ NSString *text;
+ UIFont *font;
+ UIColor *textColor;
+ UITextAlignment textAlignment;
+ NSRange selectedRange;
+ BOOL editable;
+ UIDataDetectorTypes dataDetectorTypes;
+ UIReturnKeyType returnKeyType;
+}
+
+//real class properties
+@property int maxNumberOfLines;
+@property int minNumberOfLines;
+@property BOOL animateHeightChange;
+@property (retain) 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(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;
+
+
+//uitextview methods
+- (BOOL)hasText;
+- (void)scrollRangeToVisible:(NSRange)range;
+
+@end
419 class/HPGrowingTextView.m
@@ -0,0 +1,419 @@
+//
+// HPTextView.m
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "HPGrowingTextView.h"
+#import "HPTextViewInternal.h"
+
+
+@implementation HPGrowingTextView
+@synthesize internalTextView;
+@synthesize maxNumberOfLines;
+@synthesize minNumberOfLines;
+@synthesize delegate;
+
+@synthesize text;
+@synthesize font;
+@synthesize textColor;
+@synthesize textAlignment;
+@synthesize selectedRange;
+@synthesize editable;
+@synthesize dataDetectorTypes;
+@synthesize animateHeightChange;
+@synthesize returnKeyType;
+
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ // Initialization code
+ CGRect r = frame;
+ r.origin.y = 0;
+ r.origin.x = 0;
+
+ internalTextView = [[HPTextViewInternal alloc] initWithFrame:r];
+ internalTextView.delegate = self;
+ internalTextView.scrollEnabled = NO;
+ internalTextView.font = [UIFont fontWithName:@"Helvetica" size:13];
+ internalTextView.contentInset = UIEdgeInsetsZero;
+ internalTextView.showsHorizontalScrollIndicator = NO;
+ internalTextView.text = @"-";
+ [self addSubview:internalTextView];
+
+ UIView *internal = (UIView*)[[internalTextView subviews] objectAtIndex:0];
+ minHeight = internal.frame.size.height;
+ minNumberOfLines = 1;
+
+ animateHeightChange = YES;
+
+ internalTextView.text = @"";
+
+ [self setMaxNumberOfLines:3];
+ }
+ return self;
+}
+
+-(void)sizeToFit
+{
+ CGRect r = self.frame;
+ r.size.height = minHeight;
+ self.frame = r;
+}
+
+-(void)setFrame:(CGRect)aframe
+{
+ CGRect r = aframe;
+ r.origin.y = 0;
+ r.origin.x = 0;
+ internalTextView.frame = r;
+
+ [super setFrame:aframe];
+}
+
+-(void)setMaxNumberOfLines:(int)n
+{
+ UITextView *test = [[HPTextViewInternal alloc] init];
+ test.font = internalTextView.font;
+ test.hidden = YES;
+
+ NSMutableString *newLines = [NSMutableString string];
+
+ if(n == 1){
+ [newLines appendString:@"-"];
+ } else {
+ for(int i = 1; i<n; i++){
+ [newLines appendString:@"\n"];
+ }
+ }
+
+ test.text = newLines;
+
+
+ [self addSubview:test];
+
+ maxHeight = test.contentSize.height;
+ maxNumberOfLines = n;
+
+ [test removeFromSuperview];
+ [test release];
+}
+
+-(void)setMinNumberOfLines:(int)m
+{
+
+ UITextView *test = [[HPTextViewInternal alloc] init];
+ test.font = internalTextView.font;
+ test.hidden = YES;
+
+ NSMutableString *newLines = [NSMutableString string];
+
+ if(m == 1){
+ [newLines appendString:@"-"];
+ } else {
+ for(int i = 1; i<m; i++){
+ [newLines appendString:@"\n"];
+ }
+ }
+
+ test.text = newLines;
+
+
+ [self addSubview:test];
+
+ minHeight = test.contentSize.height;
+
+ [self sizeToFit];
+ minNumberOfLines = m;
+
+ [test removeFromSuperview];
+ [test release];
+}
+
+
+- (void)textViewDidChange:(UITextView *)textView
+{
+ //size of content, so we can set the frame of self
+ NSInteger newSizeH = internalTextView.contentSize.height;
+ if(newSizeH < minHeight || !internalTextView.hasText) newSizeH = minHeight; //not smalles than minHeight
+
+ if (internalTextView.frame.size.height != newSizeH)
+ {
+ if (newSizeH <= maxHeight)
+ {
+ if(animateHeightChange){
+ [UIView beginAnimations:@"" context:nil];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(growDidStop)];
+ [UIView setAnimationBeginsFromCurrentState:YES];
+ }
+
+ if ([delegate respondsToSelector:@selector(growingTextView:willChangeHeight:)]) {
+ [delegate growingTextView:self willChangeHeight:newSizeH];
+ }
+
+ // internalTextView
+ CGRect internalTextViewFrame = self.frame;
+ internalTextViewFrame.size.height = newSizeH; // + padding
+ self.frame = internalTextViewFrame;
+
+ internalTextViewFrame.origin.y = 0;
+ internalTextViewFrame.origin.x = 0;
+ internalTextView.frame = internalTextViewFrame;
+
+ if(animateHeightChange){
+ [UIView commitAnimations];
+ }
+ }
+
+
+ // if our new height is greater than the maxHeight
+ // sets not set the height or move things
+ // around and enable scrolling
+ if (newSizeH >= maxHeight)
+ {
+ if(!internalTextView.scrollEnabled){
+ internalTextView.scrollEnabled = YES;
+ [internalTextView flashScrollIndicators];
+ }
+
+ } else {
+ internalTextView.scrollEnabled = NO;
+ }
+
+ }
+
+
+ if ([delegate respondsToSelector:@selector(growingTextViewDidChange:)]) {
+ [delegate growingTextViewDidChange:self];
+ }
+
+}
+
+-(void)growDidStop
+{
+ if ([delegate respondsToSelector:@selector(growingTextView:didChangeHeight:)]) {
+ [delegate growingTextView:self didChangeHeight:self.frame.size.height];
+ }
+
+}
+
+-(BOOL)resignFirstResponder
+{
+ [super resignFirstResponder];
+ return [internalTextView resignFirstResponder];
+}
+
+- (void)dealloc {
+ [internalTextView release];
+ [super dealloc];
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark UITextView properties
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setText:(NSString *)atext
+{
+ internalTextView.text= atext;
+}
+//
+-(NSString*)text
+{
+ return internalTextView.text;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setFont:(UIFont *)afont
+{
+ internalTextView.font= afont;
+
+ [self setMaxNumberOfLines:maxNumberOfLines];
+ [self setMinNumberOfLines:minNumberOfLines];
+}
+
+-(UIFont *)font
+{
+ return internalTextView.font;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setTextColor:(UIColor *)color
+{
+ internalTextView.textColor = color;
+}
+
+-(UIColor*)textColor{
+ return internalTextView.textColor;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setTextAlignment:(UITextAlignment)aligment
+{
+ internalTextView.textAlignment = aligment;
+}
+
+-(UITextAlignment)textAlignment
+{
+ return internalTextView.textAlignment;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setSelectedRange:(NSRange)range
+{
+ internalTextView.selectedRange = range;
+}
+
+-(NSRange)selectedRange
+{
+ return internalTextView.selectedRange;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setEditable:(BOOL)beditable
+{
+ internalTextView.editable = beditable;
+}
+
+-(BOOL)isEditable
+{
+ return internalTextView.editable;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setReturnKeyType:(UIReturnKeyType)keyType
+{
+ internalTextView.returnKeyType = keyType;
+}
+
+-(UIReturnKeyType)returnKeyType
+{
+ return internalTextView.returnKeyType;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setDataDetectorTypes:(UIDataDetectorTypes)datadetector
+{
+ internalTextView.dataDetectorTypes = datadetector;
+}
+
+-(UIDataDetectorTypes)dataDetectorTypes
+{
+ return internalTextView.dataDetectorTypes;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (BOOL)hasText{
+ return [internalTextView hasText];
+}
+
+- (void)scrollRangeToVisible:(NSRange)range
+{
+ [internalTextView scrollRangeToVisible:range];
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+#pragma mark UITextViewDelegate
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewShouldBeginEditing:)]) {
+ return [delegate growingTextViewShouldBeginEditing:self];
+
+ } else {
+ return YES;
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewShouldEndEditing:)]) {
+ return [delegate growingTextViewShouldEndEditing:self];
+
+ } else {
+ return YES;
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)textViewDidBeginEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewDidBeginEditing:)]) {
+ [delegate growingTextViewDidBeginEditing:self];
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)textViewDidEndEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewDidEndEditing:)]) {
+ [delegate growingTextViewDidEndEditing:self];
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
+ replacementText:(NSString *)atext {
+
+ //weird 1 pixel bug when clicking backspace when textView is empty
+ if(![textView hasText] && [atext isEqualToString:@""]) return NO;
+
+ if ([atext isEqualToString:@"\n"]) {
+ if ([delegate respondsToSelector:@selector(growingTextViewShouldReturn:)]) {
+ if (![delegate performSelector:@selector(growingTextViewShouldReturn:) withObject:self]) {
+ return YES;
+ } else {
+ [textView resignFirstResponder];
+ return NO;
+ }
+ }
+ }
+
+ return YES;
+
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)textViewDidChangeSelection:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewDidChangeSelection:)]) {
+ [delegate growingTextViewDidChangeSelection:self];
+ }
+}
+
+@end
34 class/HPTextViewInternal.h
@@ -0,0 +1,34 @@
+//
+// HPTextViewInternal.h
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <UIKit/UIKit.h>
+
+
+@interface HPTextViewInternal : UITextView {
+}
+
+@end
66 class/HPTextViewInternal.m
@@ -0,0 +1,66 @@
+//
+// HPTextViewInternal.m
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "HPTextViewInternal.h"
+
+
+@implementation HPTextViewInternal
+
+-(void)setContentOffset:(CGPoint)s
+{
+ if(self.tracking || self.decelerating){
+ //initiated by user...
+ self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
+ } else {
+
+ float bottomOffset = (self.contentSize.height - self.frame.size.height + self.contentInset.bottom);
+ if(s.y < bottomOffset && self.scrollEnabled){
+ self.contentInset = UIEdgeInsetsMake(0, 0, 8, 0); //maybe use scrollRangeToVisible?
+ }
+
+ }
+
+ [super setContentOffset:s];
+}
+
+-(void)setContentInset:(UIEdgeInsets)s
+{
+ UIEdgeInsets insets = s;
+
+ if(s.bottom>8) insets.bottom = 0;
+ insets.top = 0;
+
+ [super setContentInset:insets];
+}
+
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+
+@end
41 example/Classes/GrowingTextViewExampleAppDelegate.h
@@ -0,0 +1,41 @@
+//
+// GrowingTextViewExampleAppDelegate.h
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <UIKit/UIKit.h>
+
+@class GrowingTextViewExampleViewController;
+
+@interface GrowingTextViewExampleAppDelegate : NSObject <UIApplicationDelegate> {
+ UIWindow *window;
+ GrowingTextViewExampleViewController *viewController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) GrowingTextViewExampleViewController *viewController;
+
+@end
+
109 example/Classes/GrowingTextViewExampleAppDelegate.m
@@ -0,0 +1,109 @@
+//
+// GrowingTextViewExampleAppDelegate.m
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "GrowingTextViewExampleAppDelegate.h"
+#import "GrowingTextViewExampleViewController.h"
+
+@implementation GrowingTextViewExampleAppDelegate
+
+@synthesize window;
+@synthesize viewController;
+
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+
+ // Override point for customization after application launch.
+
+ viewController = [[GrowingTextViewExampleViewController alloc] init];
+
+ // Add the view controller's view to the window and display.
+ [window addSubview:viewController.view];
+ [window makeKeyAndVisible];
+
+ return YES;
+}
+
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ /*
+ Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ */
+}
+
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ /*
+ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
+ */
+}
+
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ /*
+ Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
+ */
+}
+
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ /*
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ */
+}
+
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ /*
+ Called when the application is about to terminate.
+ See also applicationDidEnterBackground:.
+ */
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ /*
+ Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
+ */
+}
+
+
+- (void)dealloc {
+ [viewController release];
+ [window release];
+ [super dealloc];
+}
+
+
+@end
38 example/Classes/GrowingTextViewExampleViewController.h
@@ -0,0 +1,38 @@
+//
+// GrowingTextViewExampleViewController.h
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <UIKit/UIKit.h>
+#import "HPGrowingTextView.h"
+
+@interface GrowingTextViewExampleViewController : UIViewController <HPGrowingTextViewDelegate>{
+ HPGrowingTextView *textView;
+}
+
+-(void)resignTextView;
+
+@end
+
162 example/Classes/GrowingTextViewExampleViewController.m
@@ -0,0 +1,162 @@
+//
+// GrowingTextViewExampleViewController.m
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "GrowingTextViewExampleViewController.h"
+
+@implementation GrowingTextViewExampleViewController
+
+
+-(id)init
+{
+ self = [super init];
+ if(self){
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillShow:)
+ name:UIKeyboardWillShowNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillHide:)
+ name:UIKeyboardWillHideNotification
+ object:nil];
+ }
+
+ return self;
+}
+
+
+
+// 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.backgroundColor = [UIColor grayColor];
+
+ textView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
+ textView.minNumberOfLines = 1;
+ textView.maxNumberOfLines = 4;
+ textView.returnKeyType = UIReturnKeyGo; //just as an example
+ textView.font = [UIFont boldSystemFontOfSize:15.0f];
+ textView.delegate = self;
+ //textView.animateHeightChange = NO; //turns off animation
+
+ [self.view addSubview:textView];
+ [textView sizeToFit];
+
+ UIButton *doneBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ doneBtn.frame = CGRectMake(30, 30, 260, 80);
+ [doneBtn setTitle:@"Done" forState:UIControlStateNormal];
+ [doneBtn addTarget:self action:@selector(resignTextView) forControlEvents:UIControlEventTouchUpInside];
+ [self.view addSubview:doneBtn];
+
+ CGRect r = textView.frame;
+ r.origin.y = self.view.frame.size.height - r.size.height;
+ textView.frame = r;
+}
+
+-(void)resignTextView
+{
+ NSLog(@"???");
+ [textView resignFirstResponder];
+}
+
+//Code from Brett Schumann
+-(void) keyboardWillShow:(NSNotification *)note{
+ // get keyboard size and loctaion
+ CGRect keyboardBounds;
+ [[note.userInfo valueForKey:UIKeyboardBoundsUserInfoKey] getValue: &keyboardBounds];
+
+ // get the height since this is the main value that we need.
+ NSInteger kbSizeH = keyboardBounds.size.height;
+
+ // get a rect for the textView frame
+ CGRect textViewFrame = textView.frame;
+ textViewFrame.origin.y -= kbSizeH;
+
+ // animations settings
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationBeginsFromCurrentState:YES];
+ [UIView setAnimationDuration:0.3f];
+
+ // set views with new info
+ textView.frame = textViewFrame;
+
+ // commit animations
+ [UIView commitAnimations];
+}
+
+-(void) keyboardWillHide:(NSNotification *)note{
+ // get keyboard size and location
+ CGRect keyboardBounds;
+ [[note.userInfo valueForKey:UIKeyboardBoundsUserInfoKey] getValue: &keyboardBounds];
+
+ // get the height since this is the main value that we need.
+ NSInteger kbSizeH = keyboardBounds.size.height;
+
+ // get a rect for the textView frame
+ CGRect textViewFrame = textView.frame;
+ textViewFrame.origin.y += kbSizeH;
+
+ // animations settings
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationBeginsFromCurrentState:YES];
+ [UIView setAnimationDuration:0.3f];
+
+ // set views with new info
+ textView.frame = textViewFrame;
+
+ // commit animations
+ [UIView commitAnimations];
+}
+
+- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height
+{
+ float diff = (textView.frame.size.height - height);
+
+ CGRect r = textView.frame;
+ r.origin.y += diff;
+ textView.frame = r;
+}
+
+- (void)didReceiveMemoryWarning {
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc that aren't in use.
+}
+
+- (void)viewDidUnload {
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+
+- (void)dealloc {
+ [textView release];
+ [super dealloc];
+}
+
+@end
99 example/Classes/HPGrowingTextView.h
@@ -0,0 +1,99 @@
+//
+// HPTextView.h
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <UIKit/UIKit.h>
+
+@class HPGrowingTextView;
+@class HPTextViewInternal;
+
+@protocol HPGrowingTextViewDelegate
+
+@optional
+- (BOOL)growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView;
+- (BOOL)growingTextViewShouldEndEditing:(HPGrowingTextView *)growingTextView;
+
+- (void)growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView;
+- (void)growingTextViewDidEndEditing:(HPGrowingTextView *)growingTextView;
+
+- (BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
+- (void)growingTextViewDidChange:(HPGrowingTextView *)growingTextView;
+
+- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height;
+- (void)growingTextView:(HPGrowingTextView *)growingTextView didChangeHeight:(float)height;
+
+- (void)growingTextViewDidChangeSelection:(HPGrowingTextView *)growingTextView;
+- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView;
+@end
+
+@interface HPGrowingTextView : UIView <UITextViewDelegate> {
+ HPTextViewInternal *internalTextView;
+
+ int minHeight;
+ int maxHeight;
+
+ //class properties
+ int maxNumberOfLines;
+ int minNumberOfLines;
+
+ BOOL animateHeightChange;
+
+ //uitextview properties
+ NSObject <HPGrowingTextViewDelegate> *delegate;
+ NSString *text;
+ UIFont *font;
+ UIColor *textColor;
+ UITextAlignment textAlignment;
+ NSRange selectedRange;
+ BOOL editable;
+ UIDataDetectorTypes dataDetectorTypes;
+ UIReturnKeyType returnKeyType;
+}
+
+//real class properties
+@property int maxNumberOfLines;
+@property int minNumberOfLines;
+@property BOOL animateHeightChange;
+@property (retain) 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(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;
+
+
+//uitextview methods
+- (BOOL)hasText;
+- (void)scrollRangeToVisible:(NSRange)range;
+
+@end
419 example/Classes/HPGrowingTextView.m
@@ -0,0 +1,419 @@
+//
+// HPTextView.m
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "HPGrowingTextView.h"
+#import "HPTextViewInternal.h"
+
+
+@implementation HPGrowingTextView
+@synthesize internalTextView;
+@synthesize maxNumberOfLines;
+@synthesize minNumberOfLines;
+@synthesize delegate;
+
+@synthesize text;
+@synthesize font;
+@synthesize textColor;
+@synthesize textAlignment;
+@synthesize selectedRange;
+@synthesize editable;
+@synthesize dataDetectorTypes;
+@synthesize animateHeightChange;
+@synthesize returnKeyType;
+
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ // Initialization code
+ CGRect r = frame;
+ r.origin.y = 0;
+ r.origin.x = 0;
+
+ internalTextView = [[HPTextViewInternal alloc] initWithFrame:r];
+ internalTextView.delegate = self;
+ internalTextView.scrollEnabled = NO;
+ internalTextView.font = [UIFont fontWithName:@"Helvetica" size:13];
+ internalTextView.contentInset = UIEdgeInsetsZero;
+ internalTextView.showsHorizontalScrollIndicator = NO;
+ internalTextView.text = @"-";
+ [self addSubview:internalTextView];
+
+ UIView *internal = (UIView*)[[internalTextView subviews] objectAtIndex:0];
+ minHeight = internal.frame.size.height;
+ minNumberOfLines = 1;
+
+ animateHeightChange = YES;
+
+ internalTextView.text = @"";
+
+ [self setMaxNumberOfLines:3];
+ }
+ return self;
+}
+
+-(void)sizeToFit
+{
+ CGRect r = self.frame;
+ r.size.height = minHeight;
+ self.frame = r;
+}
+
+-(void)setFrame:(CGRect)aframe
+{
+ CGRect r = aframe;
+ r.origin.y = 0;
+ r.origin.x = 0;
+ internalTextView.frame = r;
+
+ [super setFrame:aframe];
+}
+
+-(void)setMaxNumberOfLines:(int)n
+{
+ UITextView *test = [[HPTextViewInternal alloc] init];
+ test.font = internalTextView.font;
+ test.hidden = YES;
+
+ NSMutableString *newLines = [NSMutableString string];
+
+ if(n == 1){
+ [newLines appendString:@"-"];
+ } else {
+ for(int i = 1; i<n; i++){
+ [newLines appendString:@"\n"];
+ }
+ }
+
+ test.text = newLines;
+
+
+ [self addSubview:test];
+
+ maxHeight = test.contentSize.height;
+ maxNumberOfLines = n;
+
+ [test removeFromSuperview];
+ [test release];
+}
+
+-(void)setMinNumberOfLines:(int)m
+{
+
+ UITextView *test = [[HPTextViewInternal alloc] init];
+ test.font = internalTextView.font;
+ test.hidden = YES;
+
+ NSMutableString *newLines = [NSMutableString string];
+
+ if(m == 1){
+ [newLines appendString:@"-"];
+ } else {
+ for(int i = 1; i<m; i++){
+ [newLines appendString:@"\n"];
+ }
+ }
+
+ test.text = newLines;
+
+
+ [self addSubview:test];
+
+ minHeight = test.contentSize.height;
+
+ [self sizeToFit];
+ minNumberOfLines = m;
+
+ [test removeFromSuperview];
+ [test release];
+}
+
+
+- (void)textViewDidChange:(UITextView *)textView
+{
+ //size of content, so we can set the frame of self
+ NSInteger newSizeH = internalTextView.contentSize.height;
+ if(newSizeH < minHeight || !internalTextView.hasText) newSizeH = minHeight; //not smalles than minHeight
+
+ if (internalTextView.frame.size.height != newSizeH)
+ {
+ if (newSizeH <= maxHeight)
+ {
+ if(animateHeightChange){
+ [UIView beginAnimations:@"" context:nil];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(growDidStop)];
+ [UIView setAnimationBeginsFromCurrentState:YES];
+ }
+
+ if ([delegate respondsToSelector:@selector(growingTextView:willChangeHeight:)]) {
+ [delegate growingTextView:self willChangeHeight:newSizeH];
+ }
+
+ // internalTextView
+ CGRect internalTextViewFrame = self.frame;
+ internalTextViewFrame.size.height = newSizeH; // + padding
+ self.frame = internalTextViewFrame;
+
+ internalTextViewFrame.origin.y = 0;
+ internalTextViewFrame.origin.x = 0;
+ internalTextView.frame = internalTextViewFrame;
+
+ if(animateHeightChange){
+ [UIView commitAnimations];
+ }
+ }
+
+
+ // if our new height is greater than the maxHeight
+ // sets not set the height or move things
+ // around and enable scrolling
+ if (newSizeH >= maxHeight)
+ {
+ if(!internalTextView.scrollEnabled){
+ internalTextView.scrollEnabled = YES;
+ [internalTextView flashScrollIndicators];
+ }
+
+ } else {
+ internalTextView.scrollEnabled = NO;
+ }
+
+ }
+
+
+ if ([delegate respondsToSelector:@selector(growingTextViewDidChange:)]) {
+ [delegate growingTextViewDidChange:self];
+ }
+
+}
+
+-(void)growDidStop
+{
+ if ([delegate respondsToSelector:@selector(growingTextView:didChangeHeight:)]) {
+ [delegate growingTextView:self didChangeHeight:self.frame.size.height];
+ }
+
+}
+
+-(BOOL)resignFirstResponder
+{
+ [super resignFirstResponder];
+ return [internalTextView resignFirstResponder];
+}
+
+- (void)dealloc {
+ [internalTextView release];
+ [super dealloc];
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark UITextView properties
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setText:(NSString *)atext
+{
+ internalTextView.text= atext;
+}
+//
+-(NSString*)text
+{
+ return internalTextView.text;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setFont:(UIFont *)afont
+{
+ internalTextView.font= afont;
+
+ [self setMaxNumberOfLines:maxNumberOfLines];
+ [self setMinNumberOfLines:minNumberOfLines];
+}
+
+-(UIFont *)font
+{
+ return internalTextView.font;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setTextColor:(UIColor *)color
+{
+ internalTextView.textColor = color;
+}
+
+-(UIColor*)textColor{
+ return internalTextView.textColor;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setTextAlignment:(UITextAlignment)aligment
+{
+ internalTextView.textAlignment = aligment;
+}
+
+-(UITextAlignment)textAlignment
+{
+ return internalTextView.textAlignment;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setSelectedRange:(NSRange)range
+{
+ internalTextView.selectedRange = range;
+}
+
+-(NSRange)selectedRange
+{
+ return internalTextView.selectedRange;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setEditable:(BOOL)beditable
+{
+ internalTextView.editable = beditable;
+}
+
+-(BOOL)isEditable
+{
+ return internalTextView.editable;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setReturnKeyType:(UIReturnKeyType)keyType
+{
+ internalTextView.returnKeyType = keyType;
+}
+
+-(UIReturnKeyType)returnKeyType
+{
+ return internalTextView.returnKeyType;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+-(void)setDataDetectorTypes:(UIDataDetectorTypes)datadetector
+{
+ internalTextView.dataDetectorTypes = datadetector;
+}
+
+-(UIDataDetectorTypes)dataDetectorTypes
+{
+ return internalTextView.dataDetectorTypes;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (BOOL)hasText{
+ return [internalTextView hasText];
+}
+
+- (void)scrollRangeToVisible:(NSRange)range
+{
+ [internalTextView scrollRangeToVisible:range];
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+#pragma mark UITextViewDelegate
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewShouldBeginEditing:)]) {
+ return [delegate growingTextViewShouldBeginEditing:self];
+
+ } else {
+ return YES;
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewShouldEndEditing:)]) {
+ return [delegate growingTextViewShouldEndEditing:self];
+
+ } else {
+ return YES;
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)textViewDidBeginEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewDidBeginEditing:)]) {
+ [delegate growingTextViewDidBeginEditing:self];
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)textViewDidEndEditing:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewDidEndEditing:)]) {
+ [delegate growingTextViewDidEndEditing:self];
+ }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
+ replacementText:(NSString *)atext {
+
+ //weird 1 pixel bug when clicking backspace when textView is empty
+ if(![textView hasText] && [atext isEqualToString:@""]) return NO;
+
+ if ([atext isEqualToString:@"\n"]) {
+ if ([delegate respondsToSelector:@selector(growingTextViewShouldReturn:)]) {
+ if (![delegate performSelector:@selector(growingTextViewShouldReturn:) withObject:self]) {
+ return YES;
+ } else {
+ [textView resignFirstResponder];
+ return NO;
+ }
+ }
+ }
+
+ return YES;
+
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+- (void)textViewDidChangeSelection:(UITextView *)textView {
+ if ([delegate respondsToSelector:@selector(growingTextViewDidChangeSelection:)]) {
+ [delegate growingTextViewDidChangeSelection:self];
+ }
+}
+
+@end
34 example/Classes/HPTextViewInternal.h
@@ -0,0 +1,34 @@
+//
+// HPTextViewInternal.h
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <UIKit/UIKit.h>
+
+
+@interface HPTextViewInternal : UITextView {
+}
+
+@end
66 example/Classes/HPTextViewInternal.m
@@ -0,0 +1,66 @@
+//
+// HPTextViewInternal.m
+//
+// Created by Hans Pinckaers on 29-06-10.
+//
+// MIT License
+//
+// Copyright (c) 2011 Hans Pinckaers
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "HPTextViewInternal.h"
+
+
+@implementation HPTextViewInternal
+
+-(void)setContentOffset:(CGPoint)s
+{
+ if(self.tracking || self.decelerating){
+ //initiated by user...
+ self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
+ } else {
+
+ float bottomOffset = (self.contentSize.height - self.frame.size.height + self.contentInset.bottom);
+ if(s.y < bottomOffset && self.scrollEnabled){
+ self.contentInset = UIEdgeInsetsMake(0, 0, 8, 0); //maybe use scrollRangeToVisible?
+ }
+
+ }
+
+ [super setContentOffset:s];
+}
+
+-(void)setContentInset:(UIEdgeInsets)s
+{
+ UIEdgeInsets insets = s;
+
+ if(s.bottom>8) insets.bottom = 0;
+ insets.top = 0;
+
+ [super setContentInset:insets];
+}
+
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+
+@end
30 example/GrowingTextViewExample-Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+</dict>
+</plist>
1,490 example/GrowingTextViewExample.xcodeproj/Hans.perspectivev3
@@ -0,0 +1,1490 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>ActivePerspectiveName</key>
+ <string>Project</string>
+ <key>AllowedModules</key>
+ <array>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXSmartGroupTreeModule</string>
+ <key>Name</key>
+ <string>Groups and Files Outline View</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXNavigatorGroup</string>
+ <key>Name</key>
+ <string>Editor</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>XCTaskListModule</string>
+ <key>Name</key>
+ <string>Task List</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>XCDetailModule</string>
+ <key>Name</key>
+ <string>File and Smart Group Detail Viewer</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>1</string>
+ <key>Module</key>
+ <string>PBXBuildResultsModule</string>
+ <key>Name</key>
+ <string>Detailed Build Results Viewer</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>1</string>
+ <key>Module</key>
+ <string>PBXProjectFindModule</string>
+ <key>Name</key>
+ <string>Project Batch Find Tool</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>XCProjectFormatConflictsModule</string>
+ <key>Name</key>
+ <string>Project Format Conflicts List</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXBookmarksModule</string>
+ <key>Name</key>
+ <string>Bookmarks Tool</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXClassBrowserModule</string>
+ <key>Name</key>
+ <string>Class Browser</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXCVSModule</string>
+ <key>Name</key>
+ <string>Source Code Control Tool</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXDebugBreakpointsModule</string>
+ <key>Name</key>
+ <string>Debug Breakpoints Tool</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>XCDockableInspector</string>
+ <key>Name</key>
+ <string>Inspector</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>PBXOpenQuicklyModule</string>
+ <key>Name</key>
+ <string>Open Quickly Tool</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>1</string>
+ <key>Module</key>
+ <string>PBXDebugSessionModule</string>
+ <key>Name</key>
+ <string>Debugger</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>1</string>
+ <key>Module</key>
+ <string>PBXDebugCLIModule</string>
+ <key>Name</key>
+ <string>Debug Console</string>
+ </dict>
+ <dict>
+ <key>BundleLoadPath</key>
+ <string></string>
+ <key>MaxInstances</key>
+ <string>n</string>
+ <key>Module</key>
+ <string>XCSnapshotModule</string>
+ <key>Name</key>
+ <string>Snapshots Tool</string>
+ </dict>
+ </array>
+ <key>BundlePath</key>
+ <string>/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources</string>
+ <key>Description</key>
+ <string>AIODescriptionKey</string>
+ <key>DockingSystemVisible</key>
+ <false/>
+ <key>Extension</key>
+ <string>perspectivev3</string>
+ <key>FavBarConfig</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>3A09CE8E11DBF2BE00263BEC</string>
+ <key>XCBarModuleItemNames</key>
+ <dict/>
+ <key>XCBarModuleItems</key>
+ <array/>
+ </dict>
+ <key>FirstTimeWindowDisplayed</key>
+ <false/>
+ <key>Identifier</key>
+ <string>com.apple.perspectives.project.defaultV3</string>
+ <key>MajorVersion</key>
+ <integer>34</integer>
+ <key>MinorVersion</key>
+ <integer>0</integer>
+ <key>Name</key>
+ <string>All-In-One</string>
+ <key>Notifications</key>
+ <array/>
+ <key>OpenEditors</key>
+ <array/>
+ <key>PerspectiveWidths</key>
+ <array>
+ <integer>994</integer>
+ <integer>994</integer>
+ </array>
+ <key>Perspectives</key>
+ <array>
+ <dict>
+ <key>ChosenToolbarItems</key>
+ <array>
+ <string>XCToolbarPerspectiveControl</string>
+ <string>NSToolbarSeparatorItem</string>
+ <string>active-combo-popup</string>
+ <string>action</string>
+ <string>NSToolbarFlexibleSpaceItem</string>
+ <string>debugger-enable-breakpoints</string>
+ <string>build-and-go</string>
+ <string>com.apple.ide.PBXToolbarStopButton</string>
+ <string>get-info</string>
+ <string>NSToolbarFlexibleSpaceItem</string>
+ <string>com.apple.pbx.toolbar.searchfield</string>
+ </array>
+ <key>ControllerClassBaseName</key>
+ <string></string>
+ <key>IconName</key>
+ <string>WindowOfProject</string>
+ <key>Identifier</key>
+ <string>perspective.project</string>
+ <key>IsVertical</key>
+ <false/>
+ <key>Layout</key>
+ <array>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXBottomSmartGroupGIDs</key>
+ <array>
+ <string>1C37FBAC04509CD000000102</string>
+ <string>1C37FAAC04509CD000000102</string>
+ <string>1C37FABC05509CD000000102</string>
+ <string>1C37FABC05539CD112110102</string>
+ <string>E2644B35053B69B200211256</string>
+ <string>1C37FABC04509CD000100104</string>
+ <string>1CC0EA4004350EF90044410B</string>
+ <string>1CC0EA4004350EF90041110B</string>
+ <string>1C77FABC04509CD000000102</string>
+ </array>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CA23ED40692098700951B8B</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Files</string>
+ <key>PBXProjectStructureProvided</key>
+ <string>yes</string>
+ <key>PBXSmartGroupTreeModuleColumnData</key>
+ <dict>
+ <key>PBXSmartGroupTreeModuleColumnWidthsKey</key>
+ <array>
+ <real>309</real>
+ </array>
+ <key>PBXSmartGroupTreeModuleColumnsKey_v4</key>
+ <array>
+ <string>MainColumn</string>
+ </array>
+ </dict>
+ <key>PBXSmartGroupTreeModuleOutlineStateKey_v7</key>
+ <dict>
+ <key>PBXSmartGroupTreeModuleOutlineStateExpansionKey</key>
+ <array>
+ <string>29B97314FDCFA39411CA2CEA</string>
+ <string>080E96DDFE201D6D7F000001</string>
+ <string>3A09CE6511DBF04800263BEC</string>
+ <string>29B97315FDCFA39411CA2CEA</string>
+ <string>29B97317FDCFA39411CA2CEA</string>
+ <string>19C28FACFE9D520D11CA2CBB</string>
+ </array>
+ <key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
+ <array>
+ <array>
+ <integer>13</integer>
+ <integer>11</integer>
+ <integer>0</integer>
+ </array>
+ </array>
+ <key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
+ <string>{{0, 0}, {309, 1211}}</string>
+ </dict>
+ <key>PBXTopSmartGroupGIDs</key>
+ <array/>
+ <key>XCIncludePerspectivesSwitch</key>
+ <false/>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 0}, {326, 1229}}</string>
+ <key>GroupTreeTableConfiguration</key>
+ <array>
+ <string>MainColumn</string>
+ <real>309</real>
+ </array>
+ <key>RubberWindowFrame</key>
+ <string>0 148 2560 1270 0 0 2560 1418 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXSmartGroupTreeModule</string>
+ <key>Proportion</key>
+ <string>326pt</string>
+ </dict>
+ <dict>
+ <key>Dock</key>
+ <array>
+ <dict>
+ <key>BecomeActive</key>
+ <true/>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>3A09CE7911DBF2B400263BEC</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>main.m</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>3A09CE7A11DBF2B400263BEC</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>main.m</string>
+ <key>_historyCapacity</key>
+ <integer>0</integer>
+ <key>bookmark</key>
+ <string>3A7BB2A4131CFD75008C3D6A</string>
+ <key>history</key>
+ <array>
+ <string>3A7BB289131CFD1E008C3D6A</string>
+ <string>3A7BB28A131CFD1E008C3D6A</string>
+ <string>3A7BB28B131CFD1E008C3D6A</string>
+ <string>3A7BB29D131CFD75008C3D6A</string>
+ <string>3A7BB29E131CFD75008C3D6A</string>
+ <string>3A7BB29F131CFD75008C3D6A</string>
+ <string>3A7BB2A0131CFD75008C3D6A</string>
+ <string>3A7BB2A1131CFD75008C3D6A</string>
+ <string>3A7BB2A2131CFD75008C3D6A</string>
+ <string>3A7BB2A3131CFD75008C3D6A</string>
+ </array>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <true/>
+ <key>XCSharingToken</key>
+ <string>com.apple.Xcode.CommonNavigatorGroupSharingToken</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 0}, {2229, 1224}}</string>
+ <key>RubberWindowFrame</key>
+ <string>0 148 2560 1270 0 0 2560 1418 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXNavigatorGroup</string>
+ <key>Proportion</key>
+ <string>1224pt</string>
+ </dict>
+ <dict>
+ <key>Proportion</key>
+ <string>0pt</string>
+ <key>Tabs</key>
+ <array>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CA23EDF0692099D00951B8B</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Detail</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{10, 27}, {2229, -27}}</string>
+ <key>RubberWindowFrame</key>
+ <string>0 148 2560 1270 0 0 2560 1418 </string>
+ </dict>
+ <key>Module</key>
+ <string>XCDetailModule</string>
+ </dict>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CA23EE00692099D00951B8B</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Project Find</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{10, 31}, {603, 297}}</string>
+ </dict>
+ <key>Module</key>
+ <string>PBXProjectFindModule</string>
+ </dict>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXCVSModuleFilterTypeKey</key>
+ <integer>1032</integer>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CA23EE10692099D00951B8B</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>SCM Results</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{10, 31}, {603, 297}}</string>
+ </dict>
+ <key>Module</key>
+ <string>PBXCVSModule</string>
+ </dict>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>XCMainBuildResultsModuleGUID</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Build Results</string>
+ <key>XCBuildResultsTrigger_Collapse</key>
+ <integer>1021</integer>
+ <key>XCBuildResultsTrigger_Open</key>
+ <integer>1011</integer>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 0}, {568, 405}}</string>
+ </dict>
+ <key>Module</key>
+ <string>PBXBuildResultsModule</string>
+ </dict>
+ </array>
+ </dict>
+ </array>
+ <key>Proportion</key>
+ <string>2229pt</string>
+ </dict>
+ </array>
+ <key>Name</key>
+ <string>Project</string>
+ <key>ServiceClasses</key>
+ <array>
+ <string>XCModuleDock</string>
+ <string>PBXSmartGroupTreeModule</string>
+ <string>XCModuleDock</string>
+ <string>PBXNavigatorGroup</string>
+ <string>XCDockableTabModule</string>
+ <string>XCDetailModule</string>
+ <string>PBXProjectFindModule</string>
+ <string>PBXCVSModule</string>
+ <string>PBXBuildResultsModule</string>
+ </array>
+ <key>TableOfContents</key>
+ <array>
+ <string>3A7BB2A5131CFD75008C3D6A</string>
+ <string>1CA23ED40692098700951B8B</string>
+ <string>3A7BB2A6131CFD75008C3D6A</string>
+ <string>3A09CE7911DBF2B400263BEC</string>
+ <string>3A7BB2A7131CFD75008C3D6A</string>
+ <string>1CA23EDF0692099D00951B8B</string>
+ <string>1CA23EE00692099D00951B8B</string>
+ <string>1CA23EE10692099D00951B8B</string>
+ <string>XCMainBuildResultsModuleGUID</string>
+ </array>
+ <key>ToolbarConfigUserDefaultsMinorVersion</key>
+ <string>2</string>
+ <key>ToolbarConfiguration</key>
+ <string>xcode.toolbar.config.defaultV3</string>
+ </dict>
+ <dict>
+ <key>ChosenToolbarItems</key>
+ <array>
+ <string>XCToolbarPerspectiveControl</string>
+ <string>NSToolbarSeparatorItem</string>
+ <string>active-combo-popup</string>
+ <string>NSToolbarFlexibleSpaceItem</string>
+ <string>debugger-enable-breakpoints</string>
+ <string>build-and-go</string>
+ <string>com.apple.ide.PBXToolbarStopButton</string>
+ <string>debugger-restart-executable</string>
+ <string>debugger-pause</string>
+ <string>debugger-step-over</string>
+ <string>debugger-step-into</string>
+ <string>debugger-step-out</string>
+ <string>NSToolbarFlexibleSpaceItem</string>
+ <string>servicesModulebreakpoints</string>
+ <string>clear-log</string>
+ <string>debugger-show-console-window</string>
+ </array>
+ <key>ControllerClassBaseName</key>
+ <string>PBXDebugSessionModule</string>
+ <key>IconName</key>
+ <string>DebugTabIcon</string>
+ <key>Identifier</key>
+ <string>perspective.debug</string>
+ <key>IsVertical</key>
+ <true/>
+ <key>Layout</key>
+ <array>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CCC7628064C1048000F2A68</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Debugger Console</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 0}, {994, 144}}</string>
+ </dict>
+ <key>Module</key>
+ <string>PBXDebugCLIModule</string>
+ <key>Proportion</key>
+ <string>144pt</string>
+ </dict>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>Debugger</key>
+ <dict>
+ <key>HorizontalSplitView</key>
+ <dict>
+ <key>_collapsingFrameDimension</key>
+ <real>0.0</real>
+ <key>_indexOfCollapsedView</key>
+ <integer>0</integer>
+ <key>_percentageOfCollapsedView</key>
+ <real>0.0</real>
+ <key>isCollapsed</key>
+ <string>yes</string>
+ <key>sizes</key>
+ <array>
+ <string>{{0, 0}, {497, 221}}</string>
+ <string>{{0, 221}, {497, 222}}</string>
+ </array>
+ </dict>
+ <key>VerticalSplitView</key>
+ <dict>
+ <key>_collapsingFrameDimension</key>
+ <real>0.0</real>
+ <key>_indexOfCollapsedView</key>
+ <integer>0</integer>
+ <key>_percentageOfCollapsedView</key>
+ <real>0.0</real>
+ <key>isCollapsed</key>
+ <string>yes</string>
+ <key>sizes</key>
+ <array>
+ <string>{{0, 0}, {497, 443}}</string>
+ <string>{{497, 0}, {497, 443}}</string>
+ </array>
+ </dict>
+ </dict>
+ <key>LauncherConfigVersion</key>
+ <string>8</string>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CCC7629064C1048000F2A68</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Debug</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>DebugConsoleVisible</key>
+ <string>None</string>
+ <key>DebugConsoleWindowFrame</key>
+ <string>{{200, 200}, {500, 300}}</string>
+ <key>DebugSTDIOWindowFrame</key>
+ <string>{{200, 200}, {500, 300}}</string>
+ <key>Frame</key>
+ <string>{{0, 149}, {994, 443}}</string>
+ <key>PBXDebugSessionStackFrameViewKey</key>
+ <dict>
+ <key>DebugVariablesTableConfiguration</key>
+ <array>
+ <string>Name</string>
+ <real>120</real>
+ <string>Value</string>
+ <real>85</real>
+ <string>Summary</string>
+ <real>267</real>
+ </array>
+ <key>Frame</key>
+ <string>{{0, 221}, {497, 222}}</string>
+ </dict>
+ </dict>
+ <key>Module</key>
+ <string>PBXDebugSessionModule</string>
+ <key>Proportion</key>
+ <string>443pt</string>
+ </dict>
+ </array>
+ <key>Name</key>
+ <string>Debug</string>
+ <key>ServiceClasses</key>
+ <array>
+ <string>XCModuleDock</string>
+ <string>PBXDebugCLIModule</string>
+ <string>PBXDebugSessionModule</string>
+ <string>PBXDebugProcessAndThreadModule</string>
+ <string>PBXDebugProcessViewModule</string>
+ <string>PBXDebugThreadViewModule</string>
+ <string>PBXDebugStackFrameViewModule</string>
+ <string>PBXNavigatorGroup</string>
+ </array>
+ <key>TableOfContents</key>
+ <array>
+ <string>3A2C274A11DBF64E0037FB64</string>
+ <string>1CCC7628064C1048000F2A68</string>
+ <string>1CCC7629064C1048000F2A68</string>
+ <string>3A2C274B11DBF64E0037FB64</string>
+ <string>3A2C274C11DBF64E0037FB64</string>
+ <string>3A2C274D11DBF64E0037FB64</string>
+ <string>3A2C274E11DBF64E0037FB64</string>
+ <string>3A2C274F11DBF64E0037FB64</string>
+ </array>
+ <key>ToolbarConfigUserDefaultsMinorVersion</key>
+ <string>2</string>
+ <key>ToolbarConfiguration</key>
+ <string>xcode.toolbar.config.debugV3</string>
+ </dict>
+ </array>
+ <key>PerspectivesBarVisible</key>
+ <true/>
+ <key>ShelfIsVisible</key>
+ <false/>
+ <key>SourceDescription</key>
+ <string>file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecification.xcperspec'</string>
+ <key>StatusbarIsVisible</key>
+ <true/>
+ <key>TimeStamp</key>
+ <real>0.0</real>
+ <key>ToolbarConfigUserDefaultsMinorVersion</key>
+ <string>2</string>
+ <key>ToolbarDisplayMode</key>
+ <integer>1</integer>
+ <key>ToolbarIsVisible</key>
+ <true/>
+ <key>ToolbarSizeMode</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Perspectives</string>
+ <key>UpdateMessage</key>
+ <string></string>
+ <key>WindowJustification</key>
+ <integer>5</integer>
+ <key>WindowOrderList</key>
+ <array>
+ <string>/Users/Hans/Downloads/GrowingTextView/example/GrowingTextViewExample.xcodeproj</string>
+ </array>
+ <key>WindowString</key>
+ <string>0 148 2560 1270 0 0 2560 1418 </string>
+ <key>WindowToolsV3</key>
+ <array>
+ <dict>
+ <key>Identifier</key>
+ <string>windowTool.debugger</string>
+ <key>Layout</key>
+ <array>
+ <dict>
+ <key>Dock</key>
+ <array>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>Debugger</key>
+ <dict>
+ <key>HorizontalSplitView</key>
+ <dict>
+ <key>_collapsingFrameDimension</key>
+ <real>0.0</real>
+ <key>_indexOfCollapsedView</key>
+ <integer>0</integer>
+ <key>_percentageOfCollapsedView</key>
+ <real>0.0</real>
+ <key>isCollapsed</key>
+ <string>yes</string>
+ <key>sizes</key>
+ <array>
+ <string>{{0, 0}, {317, 164}}</string>
+ <string>{{317, 0}, {377, 164}}</string>
+ </array>
+ </dict>
+ <key>VerticalSplitView</key>
+ <dict>
+ <key>_collapsingFrameDimension</key>
+ <real>0.0</real>
+ <key>_indexOfCollapsedView</key>
+ <integer>0</integer>
+ <key>_percentageOfCollapsedView</key>
+ <real>0.0</real>
+ <key>isCollapsed</key>
+ <string>yes</string>
+ <key>sizes</key>
+ <array>
+ <string>{{0, 0}, {694, 164}}</string>
+ <string>{{0, 164}, {694, 216}}</string>
+ </array>
+ </dict>
+ </dict>
+ <key>LauncherConfigVersion</key>
+ <string>8</string>
+ <key>PBXProjectModuleGUID</key>
+ <string>1C162984064C10D400B95A72</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Debug - GLUTExamples (Underwater)</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>DebugConsoleDrawerSize</key>
+ <string>{100, 120}</string>
+ <key>DebugConsoleVisible</key>
+ <string>None</string>
+ <key>DebugConsoleWindowFrame</key>
+ <string>{{200, 200}, {500, 300}}</string>
+ <key>DebugSTDIOWindowFrame</key>
+ <string>{{200, 200}, {500, 300}}</string>
+ <key>Frame</key>
+ <string>{{0, 0}, {694, 380}}</string>
+ <key>RubberWindowFrame</key>
+ <string>321 238 694 422 0 0 1440 878 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXDebugSessionModule</string>
+ <key>Proportion</key>
+ <string>100%</string>
+ </dict>
+ </array>
+ <key>Proportion</key>
+ <string>100%</string>
+ </dict>
+ </array>
+ <key>Name</key>
+ <string>Debugger</string>
+ <key>ServiceClasses</key>
+ <array>
+ <string>PBXDebugSessionModule</string>
+ </array>
+ <key>StatusbarIsVisible</key>
+ <integer>1</integer>
+ <key>TableOfContents</key>
+ <array>
+ <string>1CD10A99069EF8BA00B06720</string>
+ <string>1C0AD2AB069F1E9B00FABCE6</string>
+ <string>1C162984064C10D400B95A72</string>
+ <string>1C0AD2AC069F1E9B00FABCE6</string>
+ </array>
+ <key>ToolbarConfiguration</key>
+ <string>xcode.toolbar.config.debugV3</string>
+ <key>WindowString</key>
+ <string>321 238 694 422 0 0 1440 878 </string>
+ <key>WindowToolGUID</key>
+ <string>1CD10A99069EF8BA00B06720</string>
+ <key>WindowToolIsVisible</key>
+ <integer>0</integer>
+ </dict>
+ <dict>
+ <key>Identifier</key>
+ <string>windowTool.build</string>
+ <key>Layout</key>
+ <array>
+ <dict>
+ <key>Dock</key>
+ <array>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CD0528F0623707200166675</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>&lt;No Editor&gt;</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CD052900623707200166675</string>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <integer>1</integer>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 0}, {500, 215}}</string>
+ <key>RubberWindowFrame</key>
+ <string>192 257 500 500 0 0 1280 1002 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXNavigatorGroup</string>
+ <key>Proportion</key>
+ <string>218pt</string>
+ </dict>
+ <dict>
+ <key>BecomeActive</key>
+ <integer>1</integer>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>XCMainBuildResultsModuleGUID</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Build Results</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 222}, {500, 236}}</string>
+ <key>RubberWindowFrame</key>
+ <string>192 257 500 500 0 0 1280 1002 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXBuildResultsModule</string>
+ <key>Proportion</key>
+ <string>236pt</string>
+ </dict>
+ </array>
+ <key>Proportion</key>
+ <string>458pt</string>
+ </dict>
+ </array>
+ <key>Name</key>
+ <string>Build Results</string>
+ <key>ServiceClasses</key>
+ <array>
+ <string>PBXBuildResultsModule</string>
+ </array>
+ <key>StatusbarIsVisible</key>
+ <integer>1</integer>
+ <key>TableOfContents</key>
+ <array>
+ <string>1C78EAA5065D492600B07095</string>
+ <string>1C78EAA6065D492600B07095</string>
+ <string>1CD0528F0623707200166675</string>
+ <string>XCMainBuildResultsModuleGUID</string>
+ </array>
+ <key>ToolbarConfiguration</key>
+ <string>xcode.toolbar.config.buildV3</string>
+ <key>WindowString</key>
+ <string>192 257 500 500 0 0 1280 1002 </string>
+ </dict>
+ <dict>
+ <key>Identifier</key>
+ <string>windowTool.find</string>
+ <key>Layout</key>
+ <array>
+ <dict>
+ <key>Dock</key>
+ <array>
+ <dict>
+ <key>Dock</key>
+ <array>
+ <dict>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CDD528C0622207200134675</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>&lt;No Editor&gt;</string>
+ <key>PBXSplitModuleInNavigatorKey</key>
+ <dict>
+ <key>Split0</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CD0528D0623707200166675</string>
+ </dict>
+ <key>SplitCount</key>
+ <string>1</string>
+ </dict>
+ <key>StatusBarVisibility</key>
+ <integer>1</integer>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{0, 0}, {781, 167}}</string>
+ <key>RubberWindowFrame</key>
+ <string>62 385 781 470 0 0 1440 878 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXNavigatorGroup</string>
+ <key>Proportion</key>
+ <string>781pt</string>
+ </dict>
+ </array>
+ <key>Proportion</key>
+ <string>50%</string>
+ </dict>
+ <dict>
+ <key>BecomeActive</key>
+ <integer>1</integer>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>1CD0528E0623707200166675</string>
+ <key>PBXProjectModuleLabel</key>
+ <string>Project Find</string>
+ </dict>
+ <key>GeometryConfiguration</key>
+ <dict>
+ <key>Frame</key>
+ <string>{{8, 0}, {773, 254}}</string>
+ <key>RubberWindowFrame</key>
+ <string>62 385 781 470 0 0 1440 878 </string>
+ </dict>
+ <key>Module</key>
+ <string>PBXProjectFindModule</string>
+ <key>Proportion</key>
+ <string>50%</string>
+ </dict>
+ </array>
+ <key>Proportion</key>