UIScrollViewDelegate methods and touches with customized UITextView
UIScrollViewDelegate methods and touches with customized UITextView
- Subject: UIScrollViewDelegate methods and touches with customized UITextView
- From: "Ignacio Enriquez" <email@hidden>
- Date: Sun, 2 Nov 2008 01:23:19 +0900
Hello everyone,
I am quite new in implementing Delegates protocols and assignating
them. And I am having some kind of problems here.
I am trying to get the exact position of a text (using offset method
of UITextView) when scrolled
for that reason I have decide to adopt UIScrollViewDelegate and
implemented , let's say -
(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
And at the same time I have to be able to respond to touches. That's
is why I have decided to subclass UITextView , a class named
EVLessonTextView, and write touch methods like -
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event inside
there.
And a text view controller class that has some info like, the text to
be shown, the current text position and whether text viewer has been
touched or not.
The problem is, my app does not respond as expected. I think is has
something to be with assignation of delegates.
This a short version of what I wrote. But I hope I can learn from this.
Could you tell me what am I mistaking in?
// text view
@interface EVLessonTextView : UITextView {
NSNumber * currentPosition;
}
@end
@implementation EVLessonTextView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"Ouch!!, text has been touched");
[super touchesBegan:touches withEvent:event];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"view didScroll!!, current position has been calculated");
}
//text view controller
@interface EVTextViewController : UIViewController
<UITextViewDelegate, UIScrollViewDelegate> {
IBOutlet EVLessonTextView * textView;
NSNumber *currentTextPosition;
Boolean *textHasBeenTouched;
}
- (void)viewDidLoad {
[super viewDidLoad];
textView.delegate = textView; // GETS A WARNING here,
EVLessonTextView does not implement UITextViewDelegate protocol
textView.text = @"super ultra long scrollable text content";
textView.editable = NO;
}
in the part I get a warning, If write
textView.delegate = textView
then only scroll methods works fine, but I have a warning
if I change it to
textView.delegate = self
then I got nothing, not warning, but not scrolling methods and not
even touches methods.
What is wrong?
I am kind of stacked here.
Thanks in advance for your help.
Ignacio
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden