2014-12-19 2 views
-1

UIScrollView에있는 여러 줄 UITextView가 있습니다. 편집 및 선택이 가능하도록 구성되어 있으므로 표준 선택/모두 선택 등의 메뉴가 길게 열립니다. Select All을 누르면 첫 번째 줄의 선택 부분 만 조정할 수 있습니다. 선택 항목이 첫 번째 줄을 포함하지 않도록 변경되면 선택 핸들이 더 이상 터치 입력에 응답하지 않습니다.UIScrollView에서 여러 줄 UITextView가 작동하지 않습니다.

첫 번째 줄에서 한 단어를 선택하면 왼쪽 선택 핸들이 정상적으로 작동하지만 오른쪽 핸들은 터치 입력을받지 못합니다.

어떤 아이디어가 원인 일 수 있습니까? 이것은 매우 이상하고 나는 실제로 무슨 일이 일어나는지 알 수 없습니다. 나는 제스처를 무시하지 않고 있습니다. (어쨌든 말할 수 있습니다.)

답변

0

아, 알아 냈어. 텍스트보기는 예상대로 다른보기 안에 있지만 부모보기에서 사용자 지정 검색이있었습니다. In -hitTest : withEvent : 편집 모드에있는 경우 텍스트 뷰에서 hitTest를 호출하는 대신 텍스트 뷰 자체를 반환하므로 선택 뷰를 반환해야하는지 확인할 수 있습니다.

다른보기 내부에 텍스트보기가 있고 사용자 지정 검색을 수행하는 경우 선택 기능을 잃지 않도록 필요에 따라 UITextView에서 -hitTest : withEvent :를 호출해야합니다.

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 
// a text box is tappable if: 
// a) obviously, the tap point is inside self 
// b) if current mode is unselected, check to see if a label was tapped. Because the label stretches the width of 
// the text box for layout purposes, check to see if the tap point lays inside with intrinsic content size of the 
// label. If not, pass the tap to the next subview 
// c) If the mode is already selected, ask super to return the appropriate view. 

if (!self.userInteractionEnabled || self.hidden || self.alpha <= 0.01) { 
    return nil; 
} 

CGRect touchRect = self.bounds; 

if (self.currentMode == TextBoxModeSelected) { 
    touchRect = CGRectInset(self.bounds, -22, -22); 
} 

if (CGRectContainsPoint(touchRect, point)) { 
    if (self.currentMode == TextBoxModeUnselected) { 
     return [self.readOnlyTextView hitTest:point withEvent:event]; 
    } 
    else if (self.currentMode == TextBoxModeSelected) { 
     return self; 
    } 
    else if (self.currentMode == TextBoxModeEdit) { 
     CGPoint pointInTextView = [self.editingTextView convertPoint:point fromView:self]; 

     if ([self.editingTextView pointInside:pointInTextView withEvent:event]) { 
      // PREVIOUSLY I WAS RETURNING self.editingTextView HERE 
      // self.contentView IS THE TEXT VIEW'S PARENT. LET IT DETERMINE THE 
      // SUBVIEW THAT'S BEING TAPPED. IN THE CASE OF SELECTION, IT'S UITextRangeView 
      return [self.contentView hitTest:point withEvent:event]; 
     } 
    } 
} 

return nil; 

}

관련 문제