2012-07-16 3 views
3

RTL 정렬로 UITextView이 있습니다.UITextView 정렬이 자체적으로 변경됩니다.

사용자가 텍스트를 입력하고 키보드를 닫을 경우 정렬은 그대로 유지됩니다 - RTL.

그러나 사용자가 빈 문자열을 선택하면 문자열을 자리 표시 자로 변경하고 정렬을 LTR로 바꿉니다.

RTL을 명시 적으로 요청했지만 시도가 도움이되지 않았습니다.

-(void)cancelPad{ 
    [userTextView resignFirstResponder]; 
    userTextView.textAlignment = UITextAlignmentRight; 
    userTextView.text = @"place holder text"; 
} 

-(void)doneWithNumberPad{ 
    if ([userTextView.text isEqualToString:@""]) { 
     [self cancelPad]; 
    } 
    [userTextView resignFirstResponder]; 
    userTextView.textAlignment = UITextAlignmentRight; 
} 

누군가가 아이디어가 있습니까? 첫째

답변

1

대신에 :

userTextView.text = "" 

당신은 넣어한다 : 이것은

+0

도움이되지 않았다 "시작 RTL"에 대한 UTF-8 문자 (입력해도입니다

userTextView.text = [NSString stringWithFormat:@"\u202b"]; 

이 작업은 여전히 ​​약간의 조정이 필요합니다. 시작해야합니다.) – BenB

0

: .H 파일에서 다음이 방법을 사용하고 당신의 코드를 넣어이

UIViewController<UITextFieldDelegate> 

userTextView.delegate =self; 

에 텍스트 필드를 할당 추가

-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{ 


}  
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField{ 

} 
-(BOOL) textFieldShouldReturn:(UITextField *)textField{ 

} 

예 :

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField{ 

if ([userTextView.text isEqualToString:@""]) { 
    [self cancelPad]; 
} 
[userTextView resignFirstResponder]; 
userTextView.textAlignment = UITextAlignmentRight; 
} 
+0

그것은 :( – Luda

2

마지막으로 place holder 텍스트가있는 라벨을 추가했습니다. 키보드가 표시되면 자리 표시 자 레이블이 숨겨집니다. 빈 텍스트로 키보드를 닫으면 자리 표시 자 레이블이 다시 표시됩니다. 더 적절한 해결책이 있다면 여기에 주저하지 마십시오.