0
大家好......如何從UIScrollView中獲取抽頭位置是覆蓋的UITextView
我有一個TextView作爲滾動視圖的子視圖,TextView的是覆蓋所有的滾動型區域。 我想要得到的位置水龍頭,滾動型,但是TextView的沒有通過它 的情況下,如果我挖掘的TextView,水龍頭也滾動型檢測。 我可以做到這一點?
這是我實現:
-(void)viewWillAppear:(BOOL)animated{
UIGestureRecognizer *tapScroll = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
//tapScroll.numberOfTapsRequired = 2;
[self.scrollView addGestureRecognizer:tapScroll];
self.tapGesture = (UITapGestureRecognizer *)tapScroll;
tapScroll.delegate = self;
[tapScroll release];
}
-(void)handleTap:(UITapGestureRecognizer *)recognizer{
NSLog(@"handle tap");
location = [recognizer locationInView:self.scrollView];
[self.textView becomeFirstResponder];
NSLog(@"location tap x : %f, y : %f", location.x, location.y);
if (location.y < self.view.frame.size.height - keyBoardBounds.size.height) {
NSLog(@"HEIGHT : %f", self.view.frame.size.height - keyBoardBounds.size.height);
[self.scrollView setContentOffset:CGPointZero animated:YES];
}else {
[self.scrollView setContentOffset:CGPointMake(0, location.y/2) animated:YES];
}
}
我不能讓抽頭位置,因爲TextView的沒有通過它,能有人幫助我,請嗎?
我必須做到這一點,但仍然TextView的未通過手勢,u能告訴我怎麼樣? – 2011-01-12 11:54:14