@@ -45,28 +45,28 @@ - (instancetype)initWithTextViewClass:(Class)textViewClass
4545{
4646 if (self = [super init ]) {
4747 self.textViewClass = textViewClass;
48- [self _commonInit ];
48+ [self slk_commonInit ];
4949 }
5050 return self;
5151}
5252
5353- (id )init
5454{
5555 if (self = [super init ]) {
56- [self _commonInit ];
56+ [self slk_commonInit ];
5757 }
5858 return self;
5959}
6060
6161- (instancetype )initWithCoder : (NSCoder *)coder
6262{
6363 if (self = [super initWithCoder: coder]) {
64- [self _commonInit ];
64+ [self slk_commonInit ];
6565 }
6666 return self;
6767}
6868
69- - (void )_commonInit
69+ - (void )slk_commonInit
7070{
7171 self.autoHideRightButton = YES ;
7272 self.editorContentViewHeight = 38.0 ;
@@ -78,11 +78,11 @@ - (void)_commonInit
7878 [self addSubview: self .textView];
7979 [self addSubview: self .charCountLabel];
8080
81- [self _setupViewConstraints ];
82- [self _updateConstraintConstants ];
81+ [self slk_setupViewConstraints ];
82+ [self slk_updateConstraintConstants ];
8383
84- [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (_didChangeTextViewText : ) name: UITextViewTextDidChangeNotification object: nil ];
85- [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (_didChangeTextViewContentSize : ) name: SLKTextViewContentSizeDidChangeNotification object: nil ];
84+ [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (slk_didChangeTextViewText : ) name: UITextViewTextDidChangeNotification object: nil ];
85+ [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (slk_didChangeTextViewContentSize : ) name: SLKTextViewContentSizeDidChangeNotification object: nil ];
8686
8787 [self .leftButton.imageView addObserver: self forKeyPath: NSStringFromSelector (@selector (image )) options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context: NULL ];
8888}
@@ -96,7 +96,7 @@ - (void)layoutIfNeeded
9696 return ;
9797 }
9898
99- [self _updateConstraintConstants ];
99+ [self slk_updateConstraintConstants ];
100100 [super layoutIfNeeded ];
101101}
102102
@@ -122,7 +122,7 @@ - (SLKTextView *)textView
122122 _textView = [class new ];
123123 _textView.translatesAutoresizingMaskIntoConstraints = NO ;
124124 _textView.font = [UIFont systemFontOfSize: 15.0 ];
125- _textView.maxNumberOfLines = [self _defaultNumberOfLines ];
125+ _textView.maxNumberOfLines = [self slk_defaultNumberOfLines ];
126126
127127 _textView.typingSuggestionEnabled = YES ;
128128 _textView.autocapitalizationType = UITextAutocapitalizationTypeSentences;
@@ -138,7 +138,7 @@ - (SLKTextView *)textView
138138 // Adds an aditional action to a private gesture to detect when the magnifying glass becomes visible
139139 for (UIGestureRecognizer *gesture in _textView.gestureRecognizers ) {
140140 if ([gesture isKindOfClass: NSClassFromString (@" UIVariableDelayLoupeGesture" )]) {
141- [gesture addTarget: self action: @selector (willShowLoupe : )];
141+ [gesture addTarget: self action: @selector (slk_willShowLoupe : )];
142142 }
143143 }
144144 }
@@ -235,7 +235,7 @@ - (UILabel *)charCountLabel
235235 return _charCountLabel;
236236}
237237
238- - (NSUInteger )_defaultNumberOfLines
238+ - (NSUInteger )slk_defaultNumberOfLines
239239{
240240 if (SLK_IS_IPAD ) {
241241 return 8 ;
@@ -248,7 +248,7 @@ - (NSUInteger)_defaultNumberOfLines
248248 }
249249}
250250
251- - (BOOL )limitExceeded
251+ - (BOOL )slk_limitExceeded
252252{
253253 NSString *text = [self .textView.text stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet ]];
254254
@@ -258,7 +258,7 @@ - (BOOL)limitExceeded
258258 return NO ;
259259}
260260
261- - (CGFloat)_appropriateRightButtonWidth
261+ - (CGFloat)slk_appropriateRightButtonWidth
262262{
263263 NSString *title = [self .rightButton titleForState: UIControlStateNormal];
264264 CGSize rigthButtonSize = [title sizeWithAttributes: @{NSFontAttributeName : self.rightButton .titleLabel .font }];
@@ -271,7 +271,7 @@ - (CGFloat)_appropriateRightButtonWidth
271271 return rigthButtonSize.width +self.contentInset .right ;
272272}
273273
274- - (CGFloat)_appropriateRightButtonMargin
274+ - (CGFloat)slk_appropriateRightButtonMargin
275275{
276276 if (self.autoHideRightButton ) {
277277 if (self.textView .text .length == 0 ) {
@@ -316,7 +316,7 @@ - (void)setAutoHideRightButton:(BOOL)hide
316316
317317 _autoHideRightButton = hide;
318318
319- self.rightButtonWC .constant = [self _appropriateRightButtonWidth ];
319+ self.rightButtonWC .constant = [self slk_appropriateRightButtonWidth ];
320320 [self layoutIfNeeded ];
321321}
322322
@@ -335,10 +335,10 @@ - (void)setContentInset:(UIEdgeInsets)insets
335335
336336 // Add new constraints
337337 [self removeConstraints: self .constraints];
338- [self _setupViewConstraints ];
338+ [self slk_setupViewConstraints ];
339339
340340 // Add constant values and refresh layout
341- [self _updateConstraintConstants ];
341+ [self slk_updateConstraintConstants ];
342342 [super layoutIfNeeded ];
343343}
344344
@@ -372,7 +372,7 @@ - (void)beginTextEditing
372372
373373 self.editing = YES ;
374374
375- [self _updateConstraintConstants ];
375+ [self slk_updateConstraintConstants ];
376376
377377 if (!self.isFirstResponder ) {
378378 [self layoutIfNeeded ];
@@ -386,13 +386,13 @@ - (void)endTextEdition
386386 }
387387
388388 self.editing = NO ;
389- [self _updateConstraintConstants ];
389+ [self slk_updateConstraintConstants ];
390390}
391391
392392
393393#pragma mark - Character Counter
394394
395- - (void )updateCounter
395+ - (void )slk_updateCounter
396396{
397397 NSString *text = [self .textView.text stringByTrimmingCharactersInSet: [NSCharacterSet newlineCharacterSet ]];
398398 NSString *counter = nil ;
@@ -408,13 +408,13 @@ - (void)updateCounter
408408 }
409409
410410 self.charCountLabel .text = counter;
411- self.charCountLabel .textColor = [self limitExceeded ] ? [UIColor redColor ] : [UIColor lightGrayColor ];
411+ self.charCountLabel .textColor = [self slk_limitExceeded ] ? [UIColor redColor ] : [UIColor lightGrayColor ];
412412}
413413
414414
415415#pragma mark - Magnifying Glass handling
416416
417- - (void )willShowLoupe : (UIGestureRecognizer *)gesture
417+ - (void )slk_willShowLoupe : (UIGestureRecognizer *)gesture
418418{
419419 if (gesture.state == UIGestureRecognizerStateChanged) {
420420 self.textView .loupeVisible = YES ;
@@ -434,7 +434,7 @@ - (void)willShowLoupe:(UIGestureRecognizer *)gesture
434434
435435#pragma mark - Notification Events
436436
437- - (void )_didChangeTextViewText : (NSNotification *)notification
437+ - (void )slk_didChangeTextViewText : (NSNotification *)notification
438438{
439439 SLKTextView *textView = (SLKTextView *)notification.object ;
440440
@@ -443,23 +443,21 @@ - (void)_didChangeTextViewText:(NSNotification *)notification
443443 return ;
444444 }
445445
446- NSLog (@" %s " ,__FUNCTION__);
447-
448446 // Updates the char counter label
449447 if (self.maxCharCount > 0 ) {
450- [self updateCounter ];
448+ [self slk_updateCounter ];
451449 }
452450
453451 if (self.autoHideRightButton && !self.isEditing )
454452 {
455- CGFloat rightButtonNewWidth = [self _appropriateRightButtonWidth ];
453+ CGFloat rightButtonNewWidth = [self slk_appropriateRightButtonWidth ];
456454
457455 if (self.rightButtonWC .constant == rightButtonNewWidth) {
458456 return ;
459457 }
460458
461459 self.rightButtonWC .constant = rightButtonNewWidth;
462- self.rightMarginWC .constant = [self _appropriateRightButtonMargin ];
460+ self.rightMarginWC .constant = [self slk_appropriateRightButtonMargin ];
463461
464462 if (rightButtonNewWidth > 0 ) {
465463 [self .rightButton sizeToFit ];
@@ -478,7 +476,7 @@ - (void)_didChangeTextViewText:(NSNotification *)notification
478476 }
479477}
480478
481- - (void )_didChangeTextViewContentSize : (NSNotification *)notification
479+ - (void )slk_didChangeTextViewContentSize : (NSNotification *)notification
482480{
483481 if (self.maxCharCount > 0 ) {
484482 BOOL shouldHide = (self.textView .numberOfLines == 1 ) || self.editing ;
@@ -489,7 +487,7 @@ - (void)_didChangeTextViewContentSize:(NSNotification *)notification
489487
490488#pragma mark - View Auto-Layout
491489
492- - (void )_setupViewConstraints
490+ - (void )slk_setupViewConstraints
493491{
494492 UIImage *leftButtonImg = [self .leftButton imageForState: UIControlStateNormal];
495493
@@ -535,7 +533,7 @@ - (void)_setupViewConstraints
535533 self.rightMarginWC = [self slk_constraintsForAttribute: NSLayoutAttributeTrailing][0 ];
536534}
537535
538- - (void )_updateConstraintConstants
536+ - (void )slk_updateConstraintConstants
539537{
540538 CGFloat zero = 0.0 ;
541539
@@ -563,8 +561,8 @@ - (void)_updateConstraintConstants
563561 self.leftButtonWC .constant = roundf (leftButtonSize.width );
564562 self.leftMarginWC .constant = (leftButtonSize.width > 0 ) ? self.contentInset .left : zero;
565563
566- self.rightButtonWC .constant = [self _appropriateRightButtonWidth ];
567- self.rightMarginWC .constant = [self _appropriateRightButtonMargin ];
564+ self.rightButtonWC .constant = [self slk_appropriateRightButtonWidth ];
565+ self.rightMarginWC .constant = [self slk_appropriateRightButtonMargin ];
568566 }
569567}
570568
@@ -580,7 +578,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
580578 return ;
581579 }
582580
583- [self _updateConstraintConstants ];
581+ [self slk_updateConstraintConstants ];
584582 }
585583 else {
586584 [super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
0 commit comments