일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Object-c
- 네이버
- 네이버구름
- 맥용
- goormtest
- objective-c
- iPhone
- code
- algorism
- ios
- 네이버알고리즘
- 헬스
- Swift
- error
- 구름TEST
- java
- android
- 구름알고리즘
- naver
- codility
- 코딩테스트
- 알고리즘
- 안드로이드
- 아이폰
- Cordova
- 맥북
- 아이폰 해상도
- 아이폰 비율
- 코딩
- codemonkey
Archives
- Today
- Total
그래오늘은이거야
objective c UITextField (자동으로 텍스트 이동) (자동으로 텍스트 삭제) auto text append auto text delete 3개 텍스트필드 이동 본문
세상 개발/IOS(Objective-c)
objective c UITextField (자동으로 텍스트 이동) (자동으로 텍스트 삭제) auto text append auto text delete 3개 텍스트필드 이동
jinhongstar 2020. 3. 2. 19:41728x90
반응형
UITextField
shouldChangeCharactersInRange
textField delegate use to auto add andthen delete
자동으로 텍스트필드를 이용하여 특정 자리수 체크 및 특정자리수 이상일때
아래와 같이 옵션을 설정하여 자동으로 숫자가 다음 텍스트 필드로 이동 하거나 이전 텍스트 필드로 이동하게 만들 수 있습니다.
- (BOOL)textField:(UITextField *)inputTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
//Auto next step press skill jinhong.park
if(inputTextField == firstTextField){
if (inputTextField.text.length >= 4 && range.length == 0){
// NSLog(@"4개이상");
[secondTextField setText:string];
[self secondTextFieldSelect:nil];
}
}else if(inputTextField == secondTextField){
if (inputTextField.text.length >= 4 && range.length == 0){// over press 4
// NSLog(@"4개이상");
[thirdTextField setText:string];
[self thirdTextFieldSelect:nil];
}else if(range.location == 0 && range.length == 1 && [string isEqualToString:@""]){ //back button press
[secondTextField setText:@""];
[self firstTextFieldSelect:nil];
return NO;
}
}else if(inputTextField == thirdTextField){
if(range.location == 0 && range.length == 1 && [string isEqualToString:@""]){
[thirdTextField setText:@""];
[self secondTextFieldSelect:nil];
return NO;
}
}
if (inputTextField.text.length >= 4 && range.length == 0)
return NO;
return YES;
}
3개의 텍스트 필드 버튼 타입으로 만듭니다.
- (IBAction)firstTextFieldSelect:(id)sender {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height==480) {
[mainView setContentOffset:CGPointMake(0, 340) animated:YES];
} else {
[mainView setContentOffset:CGPointMake(0, 240) animated:YES];
}
if (mainView.frame.origin.y==25) {
//[self keyboardViewUp];
}
[firstTextField becomeFirstResponder];
}
반응형
'세상 개발 > IOS(Objective-c)' 카테고리의 다른 글
Comments