카테고리 없음

[iOS Dev] English Keyboard만 사용하기

KraZYeom 2012. 1. 6. 08:26
반응형
http://www.iphonedevsdk.com/forum/iphone-sdk-development/29744-uitextfield-only-english-keyboard.html  [참고 원문]

Cocos2d 에서 영문 비트맵 폰트만 만들어 놓았는데
영문외의 글자가 들어오니 crash가 되서 영문 키보드만 필요함. 

textFiled
.keyboardType = UIKeyboardTypeASCIICapable;

한방이면 되는데! 밑에 꼼수 취소.  


다른 방법이 있는지는 모르겠지만 일단 꼼수를 공유. 

뷰가 로드 될때 [textField setSecureTextEntry:YES];
키보드가 올라 올때 
[textField setSecureTextEntry:NO]; 
 
이렇게 되면 영문 키보드만 활성화 됩니다.

- (void) keyboardWillShow{
    [textField setSecureTextEntry:NO];
}

- (void)viewDidLoad{
    [textField setSecureTextEntry:YES];

    // 키보드 활성화를 체크를 위한 옵저버 추가 
    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    [notificationCenter addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
} 
반응형