본문 바로가기

어디서든 키보드 감추기 //키보드를 사라지게 하기 위해 사용하는 재귀함수 - (void)_hideKeyboardRecursion:(UIView*)view { if ([view conformsToProtocol:@protocol(UITextInputTraits)]) { [view resignFirstResponder]; } if ([view.subviews count]>0) { for (int i = 0; i < [view.subviews count]; i++) { [self _hideKeyboardRecursion:[view.subviews objectAtIndex:i]]; } } } //키보드 감추기 - (void)hideKeyboard { UIWindow *tempWindow; for (int c=0; c < [[[UIAp.. 더보기
하위뷰에서 상위뷰 컨트롤 하는 방법 NSString *className = [NSString stringWithFormat:@"%s", object_getClassName([self.superview nextResponder])]; if ([className isEqualToString:@"XXXXlViewController"]) { [(XXXXlViewController *)[self.superview nextResponder] sizeToFit]; } 더보기
원하는 문자만 입력 받기 LEGAL 에 있는 문자만 입력 받는 방법 #define LEGAL @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " textField의 delegate의 shouldChangeCharactersInRange를 아래와 같이 구현 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:LEGAL] invertedSet]; NSString *.. 더보기
Sqlite 파일 디바이스에 저장하기 // First, test for existence. BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"TESTDB.sqlite"]; success = [fileManager fil.. 더보기