반응형

[참고: http://www.iphonesdkarticles.com/2008/11/localizing-iphone-apps.html ]

간혹 필요한 아이폰에서 사용자 언어를 리턴하는 간단한 메소드 입니다.

NSString *resultCheckLanguage = [self checkLanguage];


로 받으시면 되겠네요.

-(NSString *)checkLangauge
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
   return [[defaults objectForKey:@"AppleLanguages"] objectAtIndex:0];
}


resultCheckLanguage 결과문은

NSLog(@"current language: %@", resultCheckLanguage); 


로 확인해 보시면 아래와 같이 나옵니다. 

//한글일 때
     2012-02-27 10:58:36.167 wordList[1229:15803] current language: ko
//영어일 때
     2012-02-27 10:58:36.167 wordList[1229:15803] current language: en



반응형
반응형
어떤 개발을 하던지..
디버그 나 이벤트 관련 테스트 로는 알럿창 띄워 테스트 하는게 가장 보편적이지요.
그래서 버릇 처럼 알럿창을 제일 번저 띄워봤습니다. ㅎㅎ 
(참고 싸이트 : http://snipplr.com/view/42990/ )




1. alert 1

-(void)alertAndControl

{

    UIAlertView *alert = [[UIAlertView alloc]init];

    alert.message = @"hello";

    [alert addButtonWithTitle:@"OK"];

    [alert show];

}


alertAndControl 함수를 이벤트 시 호출해 주면 띄용~ 하고 뜹니다. ㅎㅎ
근데 이벤트 테스트 말고, 디버그는 NSLog 로 많이 사용하게 되더군요. ㅎㅎ


2. alert 2

UIAlertView *alert2 = [[UIAlertView alloc]

    initWithTitle:@"Do you really want to start the End of World?"

                          message:nil

                          delegate:self

    cancelButtonTitle:@"No, cancel Red Day"

    otherButtonTitles:@"Yes, initia", nil];

    [alert2 show];



이건 버튼 추가된 알럿입니다. 

3. alert 3 - alertView.tag 사용하기

alertView.tag 를 사용하게 되면.. 지정해준 tag 에 따라 action 을 부여할 수 있더군요.

메소드 호출 시 넘긴 값들은 
@"Lock Player Changes" :@"아줌마 잠그실꺼에요?" :1
요로케 입니다.

-(void)alertAndControl:(NSString *)alertTitle :(NSString *)alertMessage :(int)tagNo
{
    UIAlertView *alert = [[UIAlertView alloc]
 
                          initWithTitle:alertTitle
                          message:alertMessage
                          delegate:self
 
    cancelButtonTitle:@"아니오"
 
    otherButtonTitles:@"", nil];
 
    alert.tag = tagNo;    
    [alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (alertView.tag) {
        case 1:
            //1 태그 알럿 :)
            switch (buttonIndex) {
                case 1:
                    if ( nextView != nil)
                    {
                        [[parentView navigationController] pushViewController:nextView animated:YES];
 
                    }
                    break;               

                default:
                    break;
            }
            break;
        case 2:
            //2 태그 알럿 :)
            break;
        default:
            break;
    }
}



 이렇게요. 여기서 "예" 를 누르게 되면 nextView 화면으로 전환되게 코딩이 되어 있지요?
쩌업 편하네요
조금 더 작업하여 버튼까지 구현하면 완성이 될 듯 싶습니다.

반응형

+ Recent posts