2012년 1월 18일 수요일

버튼 뒤집기 ?? (카드 게임 에서 view 뒤집기 효과)


닥치고 기억을 만들면서 버튼을 터치 하면 뒤집게 하는 효과 작성에 
이용된 코드이다.



- (void) toFrontBtnImage: (UIButton *)btn
{
    UIImage * img;
    NSString * fileName;
    fileName = (NSString *)[mCountryNameArray objectAtIndex:flagsArray[btn.tag]];
    
    img = [UIImage imageNamed:fileName];        
    flagSide[btn.tag] = FRONT;
    
    CGPoint startpoint = CGPointMake(0, 0);
    [img drawAtPoint:startpoint];

    [UIView beginAnimations:@"toFrontBtnImage" context:nil];
    [UIView setAnimationDuration:ANIMATION_DURATION];
    
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btn cache:YES];
    
    [btn setImage:img forState:UIControlStateNormal];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    [UIView commitAnimations];
    btn.enabled = YES;
}

- (void) toBackBtnImage: (UIButton *)btn
{
    UIImage * img;
    img = [UIImage imageNamed:@"back.png"];
    flagSide[btn.tag] = BACK;
    
    CGPoint startpoint = CGPointMake(0, 0);
    [img drawAtPoint:startpoint];
    
    [UIView beginAnimations:@"toBackBtnImage" context:nil];
    [UIView setAnimationDuration:ANIMATION_DURATION];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; // 빠져나갈때 가속
    
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:btn cache:YES];
    
    [btn setImage:img forState:UIControlStateNormal];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    [UIView commitAnimations];
    btn.enabled = YES;
}

위 함수는 하나는 국기 모양으로 뒤집고 
하나는 백 배경으로 뒤집는다.

animationDidStop 함수를 만들어서
에니메이션이 종료하면 처리 할수 있도록 처리 한다.

- (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{
    if ([animationID isEqualToString:@"toFrontBtnImage"]){
        //처리 하고 싶은 일...
    }





2011년 11월 17일 목요일

mac osx에 Dock에서 Ctrl+마우스로 눌렀을때 최근 연 파일리스트 제거하기

만일 그럴일은 없지만 야구 동영상을 봣다치자.
그럼 Dock에서 동영상 플레이어 어플을 오래도록 클릭하거나 Ctrl+클릭을 하면
최근 파일 목록이 나온다.

나는 좀 컴퓨터를 한다.
봣다 그럼 뒷처리는 깨끗하게 처리한다.
그래 프로그램 메뉴에서 최근 연파일 -> 목록 지우기.

그래도 Dock에는 남아있다.
이걸 지우는 방법은
~/Library/Preferences

여기에 보면 프로그램 별로 파일들이 있는데
그냥 귀찮으면 프로그램이름이 들어간 파일을 모두 지워버린다.

xxx.xxx.xxx.LSSharedFileList.*를 삭제한다.

2011년 11월 13일 일요일

XCode 4.2에서 4.0시뮬레이터 사용하기

OSX 라이온 업그레이드와 함께 XCode 4.2로 업그레이드 되었다.
기존에 사용하던 프로젝트 컴파일 배포는 문제가 없긴 하지만

왠지 4.3이사만 Deployment타겟이 되는게 맘에 들지 않았다.


라이온으로 OS를 변경하고 XCode를 새로 설치해서 당연히 SDK버젼이 높아 졌지만
하위 버젼을 빌드 해야 할경우도 있을듯 하다.

XCode -> Preference -> Download

여기서 3.0 4.0 디바이스를 설치한다.

덤으로 Documentation에서 5.0 도큐먼트도 로컬에 받아두는게 좋을듯


참고 XCode 4.2에서 Storyboard로 프로젝트를 생성하면 iOS5.0에서만 동작한다.

3.x, 4.x를 지원하는 앱을 만들려면 Storyboard를 언체크 해서 기존 xib파일로 
생성해야 할듯 하다.


2011년 11월 11일 금요일

iOS alert view 클릭시 iTunes 앱 구매로 연결하기


#ifdef FREE_APP
        if(mArcadeLock)
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"lock", @"")
                                                           message:NSLocalizedString(@"free", @"")
                                                          delegate:self
                                                 cancelButtonTitle:nil
                                                 otherButtonTitles:NSLocalizedString(@"OK", @""),NSLocalizedString(@"Purchase", @""), nil];
            alert.tag = 1;
            [alert show];
            [alert release];
            return;  
        }
#endif  


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //구매 사이트 연결
    if ( buttonIndex == 1 && alertView.tag == 1)
    {
        NSURL * url = [[NSURL alloc]initWithString:NSLocalizedString(@"URL", @"")];
        [[UIApplication sharedApplication] openURL:url];
        [url release];
    }
}

UIAlertView가 여러개 있을때 어떤 AlertView에서 온 이벤트인지 구분하는 방법은
alert.tag = 값을 주고

alertView clickedButtonAtIndex: 메서드에서 분기하면된다.

NSURL 로 url을 문자열로 만들고
[[UIApplication sharedApplication] openURL:url];
로 브라우저를 링크 할수 있다.

위에 예제는 실제 sudok9에서 사용하는 것으로 로컬라이제인션을 고려해서
NSLocalizedString을 이용했고
kr / us에 따라 다른 URL을 이용하도록 하였다.

Localizable.strings 파일에 아래와 같이. (KR) 일때
"URL" = "http://itunes.apple.com/kr/app/id465633051?mt=8&ls=1";

2011년 11월 4일 금요일

xcode4 tip __MyCompanyName__ 바꾸기

xcode 3버젼에서 하던 방법으로 되지 않는다.

xcode4에서는 계정에 주소록을 가져다가 쓰는것으로 보인다.

시스템환경설정->사용자및 그룹->주소록카드 (열기)
이렇게 해서 주소록을 연다음
하단에 편집
회사를 체크 하여 회사이름을 설정한다.

이렇게 설정을 하고 xcode에서
프로젝트를 생성하면..



//  Created by  on 11. 11. 4..
//  Copyright (c) 2011 SPARROWAPPS. All rights reserved.

이러한 주석이 자동으로 생성됨을 볼수 있다.
그런데 이건 사용자 이름이 사라지고 회사 이름만 생겼다.

이전에는 
//  Created by 최준호 on 11. 10. 31..
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.

머 반즘 성공한 방법이다.
이름이 사라지고 회사이름이 제대로 나오고...
머 그리 중요한건 아닌데...

Mac 용 어플리케이션을 개발하다가

- (void)aboutMenu:(id)sender
{
[NSApp activateIgnoringOtherApps:YES];
[NSApp orderFrontStandardAboutPanel:sender];
}

위와 같은코드로 About창을 생성했을때
Credits.rtf파일로 개발자 등을 설정 할수 있는데.

이상하게 회사이름은 MyCompanyName으로 나온다.

이건 어찌 바꾸는지 모르겟음.



2011년 11월 3일 목요일

OSX Lion terminal X11 connection broken 문제

X connection to localhost:18.0 broken (explicit kill or server shutdown).

 snow leopard에서 잘사용했었는데..

ssh -X 로 접속해서 X서버를 땡겨 쓰고 했는데.
lion으로 업그레이드 하고 나니 위와 같은 에러가 가끔씩 난다

한번 나고 나면 서버에 있는 GUI프로그램을 사용할 수가 없다.

man ssh를 하면 아래와 내용을 볼 수 있다.
-X      Enables X11 forwarding.  This can also be specified on a per-host
             basis in a configuration file.

             X11 forwarding should be enabled with caution.  Users with the
             ability to bypass file permissions on the remote host (for the
             user’s X authorization database) can access the local X11 display
             through the forwarded connection.  An attacker may then be able to
             perform activities such as keystroke monitoring.

             For this reason, X11 forwarding is subjected to X11 SECURITY
             extension restrictions by default.  Please refer to the ssh -Y
             option and the ForwardX11Trusted directive in ssh_config(5) for
             more information.

     -x      Disables X11 forwarding.

     -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
             subjected to the X11 SECURITY extension controls.

-Y 옵션으로 접속하면  trusted X11 forwarding 이라고 한다.
실제로 아직까지는 연결 끊김 없이 잘 사용되고 있다.

2011년 11월 2일 수요일

소스인사이트 업그레이드 2011.5.31

이런 소스인사이트가 나도 모르게 은근 슬적 업그레이드를...

이거누가 유지 보수 하고 있엇나보다...

http://www.sourceinsight.com/changes.html

Version 3.50.0065 - May 31, 2011

Fix: Holding down the CTRL key for a long time on Vista or Windows 7 would cause the application to become gray and inactive.
Fix: Misc symbol lookup and syntax formatting fixes.
Fix: Added support for Java annotations.
Fix: General parsing errors caused by very long symbol names.
Fix: Some parsing errors that could happen in lines that end in continuation mark (\)
Fix: File seeking error that happened when the SI.LOG file got too big.