Skip to content

Commit 5eb2cf9

Browse files
author
Josip Bernat
committed
Added project.
1 parent e39b84b commit 5eb2cf9

22 files changed

+1717
-0
lines changed

CSGrowingTextView.xcodeproj/project.pbxproj

+516
Large diffs are not rendered by default.

CSGrowingTextView.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CSGrowingTextView/Base.lproj/Main.storyboard

+215
Large diffs are not rendered by default.

CSGrowingTextView/CSAppDelegate.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// CSAppDelegate.h
3+
// CSGrowingTextView
4+
//
5+
// Created by Josip Bernat on 01/03/14.
6+
// Copyright (c) 2014 Clover-Studio. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface CSAppDelegate : UIResponder <UIApplicationDelegate>
12+
13+
@property (strong, nonatomic) UIWindow *window;
14+
15+
@end

CSGrowingTextView/CSAppDelegate.m

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// CSAppDelegate.m
3+
// CSGrowingTextView
4+
//
5+
// Created by Josip Bernat on 01/03/14.
6+
// Copyright (c) 2014 Clover-Studio. All rights reserved.
7+
//
8+
9+
#import "CSAppDelegate.h"
10+
11+
@implementation CSAppDelegate
12+
13+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
14+
{
15+
// Override point for customization after application launch.
16+
return YES;
17+
}
18+
19+
- (void)applicationWillResignActive:(UIApplication *)application
20+
{
21+
// 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.
22+
// 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.
23+
}
24+
25+
- (void)applicationDidEnterBackground:(UIApplication *)application
26+
{
27+
// 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.
28+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29+
}
30+
31+
- (void)applicationWillEnterForeground:(UIApplication *)application
32+
{
33+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34+
}
35+
36+
- (void)applicationDidBecomeActive:(UIApplication *)application
37+
{
38+
// 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.
39+
}
40+
41+
- (void)applicationWillTerminate:(UIApplication *)application
42+
{
43+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44+
}
45+
46+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.clover-studio.${PRODUCT_NAME:rfc1034identifier}</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>${PRODUCT_NAME}</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1.0</string>
25+
<key>LSRequiresIPhoneOS</key>
26+
<true/>
27+
<key>UIMainStoryboardFile</key>
28+
<string>Main</string>
29+
<key>UIRequiredDeviceCapabilities</key>
30+
<array>
31+
<string>armv7</string>
32+
</array>
33+
<key>UISupportedInterfaceOrientations</key>
34+
<array>
35+
<string>UIInterfaceOrientationPortrait</string>
36+
<string>UIInterfaceOrientationLandscapeLeft</string>
37+
<string>UIInterfaceOrientationLandscapeRight</string>
38+
</array>
39+
</dict>
40+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Prefix header
3+
//
4+
// The contents of this file are implicitly included at the beginning of every source file.
5+
//
6+
7+
#import <Availability.h>
8+
9+
#ifndef __IPHONE_5_0
10+
#warning "This project uses features only available in iOS SDK 5.0 and later."
11+
#endif
12+
13+
#ifdef __OBJC__
14+
#import <UIKit/UIKit.h>
15+
#import <Foundation/Foundation.h>
16+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
//
2+
// CSGrowingTextView.h
3+
// CSGrowingTextView
4+
//
5+
// Created by Josip Bernat on 01/03/14.
6+
// Copyright (c) 2014 Clover-Studio. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
typedef NS_ENUM(NSInteger, CSGrowDirection) {
12+
CSGrowDirectionUp = 0,
13+
CSGrowDirectionDown,
14+
CSGrowDirectionNone ///CSGrowingTextView will not grow. Usefull for constraints where UIViewContoller updates height of CSGrowingTextView manually.
15+
};
16+
17+
@protocol CSGrowingTextViewDelegate;
18+
19+
/**
20+
* The CSGrowingTextView class implements the behavior for a scrollable, multiline text region that grows / shrinks while adding user inputs new text. Using minimumNumberOfLines and maximumNumberOfLines you limit number of lines displayed without shrinking / growing.
21+
*/
22+
23+
@interface CSGrowingTextView : UIView <UITextViewDelegate>
24+
25+
/**
26+
* The receiver’s delegate.
27+
*/
28+
@property (nonatomic, weak) id<CSGrowingTextViewDelegate> delegate;
29+
30+
/**
31+
* Text view used for the main textual content of the growint text view. You should be careful with direct changing it's attributes since it may affect growing text view shrinking and growing process.
32+
*/
33+
@property (nonatomic, strong, readonly) UITextView *textView;
34+
35+
/**
36+
* Label used for the placeholder textual content of the growing text view.
37+
*/
38+
@property (nonatomic, strong, readonly) UILabel *placeholderLabel;
39+
40+
/**
41+
* Minimum number of lines displayed inside growing text view without any more shrinking. Default is 1.
42+
*/
43+
@property (nonatomic, readwrite) NSUInteger minimumNumberOfLines;
44+
45+
/**
46+
* Maximum number of lines displayed inside growing text view without any more resizing. Default is 3.
47+
*/
48+
@property (nonatomic, readwrite) NSUInteger maximumNumberOfLines;
49+
50+
/**
51+
* Boolean value determening if newline character should be enabled, e.g if newline character should be treated as return key or not. Default value is NO.
52+
*/
53+
@property (nonatomic, readwrite) BOOL enablesNewlineCharacter;
54+
55+
/**
56+
* CSGrowDirection value determening in what direction should growing text view grow or shring. Default value is CSGrowDirectionUp.
57+
*/
58+
@property (nonatomic, readwrite) CSGrowDirection growDirection;
59+
60+
@end
61+
62+
@protocol CSGrowingTextViewDelegate <NSObject>
63+
64+
@optional;
65+
66+
#pragma mark - Responding to Editing Notifications
67+
68+
/**
69+
* Asks the delegate if editing should begin in the specified growing text view. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textViewShouldBeginEditing: method call.
70+
*
71+
* @param textView The growing text view for which editing is about to begin.
72+
*
73+
* @return YES if an editing session should be initiated; otherwise, NO to disallow editing.
74+
*/
75+
- (BOOL)growingTextViewShouldBeginEditing:(CSGrowingTextView *)textView;
76+
77+
/**
78+
* Tells the delegate that editing of the specified growing text view has begun. Implementation of this method is optional. This method forwards UITextViewDelegate textViewDidBeginEditing: method call.
79+
*
80+
* @param textView The growing text view in which editing began.
81+
*/
82+
- (void)growingTextViewDidBeginEditing:(CSGrowingTextView *)textView;
83+
84+
/**
85+
* Asks the delegate if editing should stop in the specified growing text view. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textViewShouldEndEditing: method call.
86+
*
87+
* @param textView The text view for which editing is about to end.
88+
*
89+
* @return YES if editing should stop; otherwise, NO if the editing session should continue.
90+
*/
91+
- (BOOL)growingTextViewShouldEndEditing:(CSGrowingTextView *)textView;
92+
93+
/**
94+
* Tells the delegate that editing of the specified growing text view has ended. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textViewDidEndEditing: method call.
95+
*
96+
* @param textView The growing text view in which editing ended.
97+
*/
98+
- (void)growingTextViewDidEndEditing:(CSGrowingTextView *)textView;
99+
100+
/**
101+
* Asks the delegate if the growing text field should process the pressing of the return button. Method is called only when enablesNewlineCharacter is set to NO. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned NO.
102+
*
103+
* @param textView The growing text view whose return button was pressed.
104+
*
105+
* @return YES if the growing text view should implement its default behavior for the return button; otherwise, NO.
106+
*/
107+
- (BOOL)growingTextViewShouldReturn:(CSGrowingTextView *)textView;
108+
109+
#pragma mark - Responding to Text Changes
110+
111+
/**
112+
* Asks the delegate whether the specified text should be replaced in the text view. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textView:shouldChangeTextInRange:replacementText: method call.
113+
*
114+
* @param textView The text view containing the changes.
115+
* @param range The current selection range. If the length of the range is 0, range reflects the current insertion point. If the user presses the Delete key, the length of the range is 1 and an empty string object replaces that single character.
116+
* @param text The text to insert.
117+
*
118+
* @return YES if the old text should be replaced by the new text; NO if the replacement operation should be aborted.
119+
*/
120+
- (BOOL)growingTextView:(CSGrowingTextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
121+
122+
/**
123+
* Tells the delegate that the text or attributes in the specified growing text view were changed by the user. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textViewDidChange: method call.
124+
*
125+
* @param textView The growing text view containing the changes.
126+
*/
127+
- (void)growingTextViewDidChange:(CSGrowingTextView *)textView;
128+
129+
#pragma mark - Responding to Selection Changes
130+
131+
/**
132+
* Tells the delegate that the text selection changed in the specified growing text view. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textViewDidChangeSelection: method call.
133+
*
134+
* @param textView The growing text view whose selection changed.
135+
*/
136+
- (void)growingTextViewDidChangeSelection:(CSGrowingTextView *)textView;
137+
138+
#pragma mark - Interacting with Text Data
139+
140+
/**
141+
* Asks the delegate if the specified growing text view should allow user interaction with the provided text attachment in the given range of text. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textView:shouldInteractWithTextAttachment:inRange: method call.
142+
*
143+
* @param textView The growing text view containing the text attachment.
144+
* @param textAttachment The text attachment.
145+
* @param characterRange The character range containing the text attachment.
146+
*
147+
* @return YES if interaction with the text attachment should be allowed; NO if interaction should not be allowed.
148+
*/
149+
- (BOOL)growingTextView:(CSGrowingTextView *)textView shouldInteractWithTextAttachment:(NSTextAttachment *)textAttachment inRange:(NSRange)characterRange NS_AVAILABLE_IOS(7_0);
150+
151+
/**
152+
* Asks the delegate if the specified growing text view should allow user interaction with the given URL in the given range of text. Implementation of this method is optional, if it is not present, editing proceeds as if this method had returned YES. This method forwards UITextViewDelegate textView:shouldInteractWithURL:inRange: method call.
153+
*
154+
* @param textView The growing text view containing the text attachment.
155+
* @param URL The URL to be processed.
156+
* @param characterRange The character range containing the URL.
157+
*
158+
* @return YES if interaction with the URL should be allowed; NO if interaction should not be allowed.
159+
*/
160+
- (BOOL)growingTextView:(CSGrowingTextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange NS_AVAILABLE_IOS(7_0);
161+
162+
#pragma mark - Height Notifications
163+
164+
/**
165+
* Tells the delegate growing text view is about to change height.
166+
*
167+
* @param growingTextView The growing text view whose height will change.
168+
* @param height The future height of the growing text view.
169+
*/
170+
- (void)growingTextView:(CSGrowingTextView *)growingTextView willChangeHeight:(CGFloat)height;
171+
172+
/**
173+
* Tells the delegate growing text view did change height.
174+
*
175+
* @param growingTextView The growing text view whose height did change.
176+
* @param height The new height of the growing text view.
177+
*/
178+
- (void)growingTextView:(CSGrowingTextView *)growingTextView didChangeHeight:(CGFloat)height;
179+
180+
@end

0 commit comments

Comments
 (0)