textview 키패드 backspace 버튼 및 다음문장(return) 버튼 이벤트 알아내기
제목이 조금 어렵나요
UITextView를 터치하고 올라오는 키패드에서 backspace 버튼과 다음문장(영어로 return) 버튼 이벤트값을 알아내는 방법 입니다.
네 아래 소스를 보면 됩니다.
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
//backspace버튼 클릭시
if (range.length == 1 && [text length] == 0) {
//이벤트처리
}
//다음문장 버튼 클릭시
else if ([text hasSuffix:@"\n"]){
//이벤트처리
}
return YES;
}
추가
현재 textview.text에 쓰여진 줄의 수 구하기
int numLines = textView.contentSize.height/customcell.textView.font.lineHeight;
반응형
그리드형
'IT > iOS' 카테고리의 다른 글
스레드 Thread (0) | 2013.07.19 |
---|---|
문자열 검색 (특정 문자 찾기) (0) | 2013.07.18 |
modalviewcontroller 띄우기 (0) | 2013.07.09 |
아이폰5 컴파일시 라이브러리 빌드 오류 (0) | 2013.06.28 |
static library 합치기 (0) | 2013.06.14 |
navigationbar background image (0) | 2013.06.04 |
tableview cell background image (0) | 2013.05.24 |
tableview 최상단으로 이동 (0) | 2013.05.23 |