아이폰에 설정된 지역 포맷(언어와 국가 정보)를 가져오려면 NSLocale 클래스를 사용한다.



지역 포맷 가져오기
1
NSLocale *currentLocale = [NSLocale currentLocale];

언어 설정 보기
1
2
3
NSLocale *currentLocale = [NSLocale currentLocale];
NSString *languageCode = [currentLocale objectForKey:NSLocaleLanguageCode];
// ko (en ...)

국가 설정 보기
1
2
3
NSLocale *currentLocale = [NSLocale currentLocale];
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
// KR (US ...)

언어와 국가 한번에 가져오기 (locale identifier)
1
2
3
NSLocale *currentLocale = [NSLocale currentLocale];
NSString *lcid = [currentLocale localeIdentifier];
// ko_KR (en_US ...)

아이폰에 설정된 언어(지역 포맷 아님)를 가져오려면 다음과 같이 할 수 있다.
1
2
3
NSString *preferredLanguageCode =
    [[NSLocale preferredLanguages] objectAtIndex:0];
// ko (en ...)

또는 NSUserDefaults 클래스를 사용할 수도 있다.
1
2
3
4
NSUserDefaults *userDefaults = [standardUserDefaults];
NSArray *languages = [userDefaults objectForKey: @"AppleLanguages"];
NSString *preferredLanguageCode = [languages objectAtIndex:0];
// ko (en ...)



[출처] https://hooni.net/57414



'Object-C > ' 카테고리의 다른 글

NSString 한글 길이를 잘 살피시라  (0) 2017.04.07
다른 ViewController 띄우기  (0) 2017.03.13
AFNetworking  (0) 2016.02.26
뷰의 터치 이벤트 통과 시키기  (0) 2015.12.16
UIView Rotating  (0) 2015.12.16

네트워크나 DB를 다룰 경우, 한글때문에 골치를 앓는 경우가 적지 않아...

대부분 이 한글관련된 경로나 파일을 찾을 수 없어 발생하게 돼, 왜 그러시냐믄

완성형이냐 조합형이냐 차이인데, 이게 Log에서는 항상 완성형으로 보여 차이를 알 수가 없어.. (Log는 인공지능인가봉가)

(완성형: 대한민국, 조합형: ㄷ ㅐ ㅎ ㅏ ㄴ ㅁ ㅣ ㄴ ㄱ ㅜ ㄱ)

확인 할 수 있는 방법이 있지 Hex로 찍어확인하는 방법도 있는데 더 간단한 방법은

바로 길이야

길이를 비교해보면 두 가지가 다르다는 것을 알 수 있지

그리고 완성형 <-> 조합형으로 적용할 수도 있다는 거야 아래와 같이


 완성형 > 조합형

[string decomposedStringWithCanonicalMapping] 


조합형 > 완성형

[string precomposedStringWithCanonicalMapping]


iOS내부적으로 조합형으로 저장을 해 두니 잘 기억해둬.

string을 Log로 찍을 때는 길이까지 함께 찍는 버릇을 두면 좋겠지 ㅎㅎ



참고 : 郎(U+F92C)의 canonical mapping에 대해


'Object-C > ' 카테고리의 다른 글

기기의 언어, 지역, 국가 설정 가져오기  (0) 2019.02.18
다른 ViewController 띄우기  (0) 2017.03.13
AFNetworking  (0) 2016.02.26
뷰의 터치 이벤트 통과 시키기  (0) 2015.12.16
UIView Rotating  (0) 2015.12.16

AppDelegate나 ViewController에서 임의의 ViewController을 띄우고 싶을 때 참고.



UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];

LoginViewController *myViewController = [storyboard instantiateViewControllerWithIdentifier:@"myViewController"];

[self.window makeKeyAndVisible];

[self.window.rootViewController presentViewController:myViewController animated:YES completion:NULL];

'Object-C > ' 카테고리의 다른 글

기기의 언어, 지역, 국가 설정 가져오기  (0) 2019.02.18
NSString 한글 길이를 잘 살피시라  (0) 2017.04.07
AFNetworking  (0) 2016.02.26
뷰의 터치 이벤트 통과 시키기  (0) 2015.12.16
UIView Rotating  (0) 2015.12.16

'Object-C > ' 카테고리의 다른 글

NSString 한글 길이를 잘 살피시라  (0) 2017.04.07
다른 ViewController 띄우기  (0) 2017.03.13
뷰의 터치 이벤트 통과 시키기  (0) 2015.12.16
UIView Rotating  (0) 2015.12.16
StatusBar hidden 하기 (Object-C)  (0) 2015.04.08

터치 시 터치이벤트가 상위 뷰로 통과하도록 하려면 이벤트를 통과시킬 뷰에 아래와 같이 설정하면 된다.

view.userInteractionEnabled = false

'Object-C > ' 카테고리의 다른 글

다른 ViewController 띄우기  (0) 2017.03.13
AFNetworking  (0) 2016.02.26
UIView Rotating  (0) 2015.12.16
StatusBar hidden 하기 (Object-C)  (0) 2015.04.08
ios8에서 sizeWithFont: is now deprecated  (0) 2015.04.07

라벨을 회전시켜 보여줘야하는 경우가 있었다.

아래와 같이 하면 가운데를 중심으로 회전이 잘 된다.

예)

self.view.transform = CGAffineTransformMakeRotation(-0.20 * M_PI);


다음 사이트에 애니메이션 주며 회전시켜주는 방법에 대해 예제와 설명이 잘되어 있다.

http://www.informit.com/blogs/blog.aspx?uk=Ask-Big-Nerd-Ranch-Rotating-an-iPhone-View-Around-a-Point



'Object-C > ' 카테고리의 다른 글

AFNetworking  (0) 2016.02.26
뷰의 터치 이벤트 통과 시키기  (0) 2015.12.16
StatusBar hidden 하기 (Object-C)  (0) 2015.04.08
ios8에서 sizeWithFont: is now deprecated  (0) 2015.04.07
레티나 단말 확인 방법  (0) 2015.04.07


참고 : http://stackoverflow.com/questions/5062978/how-can-i-dump-opengl-renderbuffer-to-png-or-jpg-image


-(UIImage *)dumpImage

{

    GLubyte *buffer = (GLubyte *) malloc(backingWidth * backingHeight * 4);

    GLubyte *buffer2 = (GLubyte *) malloc(backingWidth * backingHeight * 4);


    GLvoid *pixel_data = nil;

    glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer);


    /* make upside down */


    for (int y=0; y<backingHeight; y++) {

        for (int x=0; x<backingWidth*4; x++) {

            buffer2[y * 4 * backingWidth + x] = buffer[(backingHeight - y - 1) * backingWidth * 4 + x];

        }

    }


    // make data provider from buffer

    CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, backingWidth * backingHeight * 4, freeImageData);


    // set up for CGImage creation

    int bitsPerComponent = 8;

    int bitsPerPixel = 32;

    int bytesPerRow = 4 * backingWidth;

    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();

    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;

    // Use this to retain alpha

    //CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;

    CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

    CGImageRef imageRef = CGImageCreate(backingWidth, backingHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);


    // make UIImage from CGImage

    UIImage *newUIImage = [UIImage imageWithCGImage:imageRef];


    return newUIImage;

}


void freeImageData(void *info, const void *data, size_t size) 

{

    //printf("freeImageData called");

    free((void*)data);

}


-(BOOL)prefersStatusBarHidden{

    return YES;

}

'Object-C > ' 카테고리의 다른 글

뷰의 터치 이벤트 통과 시키기  (0) 2015.12.16
UIView Rotating  (0) 2015.12.16
ios8에서 sizeWithFont: is now deprecated  (0) 2015.04.07
레티나 단말 확인 방법  (0) 2015.04.07
4inch 모델에서 앱에 검은 여백이 생길때  (0) 2015.04.03

+ Recent posts