Permalink
Browse files

Merge pull request #4 from mikeash/master

Two small fixes, one for use in nibs and one for coordinate transforms
  • Loading branch information...
2 parents 46e2b98 + 4e128d4 commit 0399bdc864156776aa2bba3e1d098b206eecc7c0 @devindoty devindoty committed Aug 28, 2011
Showing with 44 additions and 30 deletions.
  1. +44 −30 EGOTextView/EGOTextView.m
View
@@ -187,38 +187,41 @@ @implementation EGOTextView
@synthesize enablesReturnKeyAutomatically;
+- (void)commonInit {
+ [self setText:@""];
+ self.alwaysBounceVertical = YES;
+ self.editable = YES;
+ self.font = [UIFont systemFontOfSize:17];
+ self.backgroundColor = [UIColor whiteColor];
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ self.clipsToBounds = YES;
+
+ EGOContentView *contentView = [[EGOContentView alloc] initWithFrame:CGRectInset(self.bounds, 8.0f, 8.0f)];
+ contentView.autoresizingMask = self.autoresizingMask;
+ contentView.delegate = self;
+ [self addSubview:contentView];
+ _textContentView = [contentView retain];
+ [contentView release];
+
+ UILongPressGestureRecognizer *gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
+ gesture.delegate = (id<UIGestureRecognizerDelegate>)self;
+ [self addGestureRecognizer:gesture];
+ [gesture release];
+ _longPress = gesture;
+
+ UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
+ [doubleTap setNumberOfTapsRequired:2];
+ [self addGestureRecognizer:doubleTap];
+ [doubleTap release];
+
+ UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
+ [self addGestureRecognizer:singleTap];
+ [singleTap release];
+}
+
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
-
- [self setText:@""];
- self.alwaysBounceVertical = YES;
- self.editable = YES;
- self.font = [UIFont systemFontOfSize:17];
- self.backgroundColor = [UIColor whiteColor];
- self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-
- EGOContentView *contentView = [[EGOContentView alloc] initWithFrame:CGRectInset(self.bounds, 8.0f, 8.0f)];
- contentView.autoresizingMask = self.autoresizingMask;
- contentView.delegate = self;
- [self addSubview:contentView];
- _textContentView = [contentView retain];
- [contentView release];
-
- UILongPressGestureRecognizer *gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
- gesture.delegate = (id<UIGestureRecognizerDelegate>)self;
- [self addGestureRecognizer:gesture];
- [gesture release];
- _longPress = gesture;
-
- UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
- [doubleTap setNumberOfTapsRequired:2];
- [self addGestureRecognizer:doubleTap];
- [doubleTap release];
-
- UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
- [self addGestureRecognizer:singleTap];
- [singleTap release];
-
+ [self commonInit];
}
return self;
}
@@ -228,6 +231,13 @@ - (id)init {
return self;
}
+- (id)initWithCoder: (NSCoder *)aDecoder {
+ if ((self = [super initWithCoder: aDecoder])) {
+ [self commonInit];
+ }
+ return self;
+}
+
- (void)dealloc {
_textWindow=nil;
@@ -1249,6 +1259,10 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position {
return [self caretRectForIndex:pos.index];
}
+- (UIView *)textInputView {
+ return _textContentView;
+}
+
// MARK: UITextInput - Hit testing
- (UITextPosition*)closestPositionToPoint:(CGPoint)point {

0 comments on commit 0399bdc

Please sign in to comment.