본문 바로가기

Programming

(143)
아이폰과 아이패드 UI화면 분기처리 아이폰과 아이패드에 동시에 적용되는 화면을 구성할 경우 분기처리입니다. UIDevice.h에 정의된 내용 typedef enum { #if __IPHONE_3_2
아이폰의 알림소리 다음 코드는 아이폰에 기본적으로 있는 알림소리의 경로를 얻어오는 함수 입니다. 알림 관련 어플을 제작할 때 유용하게 쓰일 거 같습니다. NSFileManager *filemgr = [NSFileManager defaultManager]; NSError *error; NSArray *fileList = [filemgr contentsOfDirectoryAtPath:@"/System/Library/Audio/UISounds/" error:&error]; for(int i = 0; i < [fileList count]; i++){ NSString *strSrc = [NSString stringWithFormat:@"/System/Library/Audio/UISounds/%@", [fileList objectA..
현재 셋팅되어 있는 언어 현재 단말에 셋팅되어 있는 언어를 반환합니다. NSString *preferredLang = [[NSLocale preferredLanguages] objectAtIndex:0];
현재시간에서 초만 제거하기 테스트 어플을 만들던 중에 정시에 알림을 울려야할 일이 생겼습니다. 기존 date를 얻어와서 초만 제거해주는식으로 만들었는데 해당 내용 공유해드립니다. 현재 시간을 얻어옴. NSDate *now = [NSDate date]; 현재시간에서 초를 읽어옴 NSCalendar *cal = [NSCalendar currentCalendar]; NSDateComponents *comp = [cal components:kCFCalendarUnitSecond fromDate:now]; NSInteger second = comp.second; 현재시간을 integer로 변환시긴후에 얻어온 초를 뺀다. double timestamp = now.timeIntervalSince1970 - second; 다시 NSDate로 변..
아이폰 가로모드 & 세로모드 화면회전과 관련된 함수는 UIInterfaceOrientation이고 UIViewController에 상속되어 있다. 호출되는 함수 // Override to allow rotation. Default returns YES only for UIInterfaceOrientationPortrait - shouldAutorotateToInterfaceOrientation // Notifies when rotation begins, reaches halfway point and ends. - willRotateToInterfaceOrientation - didRotateFromInterfaceOrientation 현재 디바이스의 모드가 어떤건지 확인 하는 함수 UIInterfaceOrientation orien..
Xcode4.2와 그 이하버전에서 iOS 5.0 분기문 처리 xCode4.2와 그 이하버전의 xCode에서 모두 쓰임이 가능한 버전 별 분기입니다. iOS 5.0 이상에서만 쓰이는 코드를 분기타기 위해서는 아래와 같이 __IPHONE_5_0 이상에서 쓰이도록 해야합니다. #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_5_0 #endif 물론 이렇게 하면 xCode4.2에서는 제대로 돌아가지만 그 이하의 xCode에서는 __IPHONE_5_0을 찾지 못해서 BAD_ACCESS가 나곤 합니다. 그래서 아래와 같이 4.3보다 크게 해야지만 정상적으로 됩니다. #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3 #endif 이제 잘 되겠지 하고 4.3 simulator에서 돌리는 순간 해당구문에..
xCode4 지역화 가장 중요한 사실 Localizable.strings 생성 http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
현재 아이폰의 IP주소 알아내기 현재 나의 아이폰에 있는 IP 주소를 나타내는 방법입니다. 출처 http://peepleware.com/home/12081 샘플 코드

반응형