레이블이 cocoa touch인 게시물을 표시합니다. 모든 게시물 표시
레이블이 cocoa touch인 게시물을 표시합니다. 모든 게시물 표시

2014년 5월 29일 목요일

[iOS] Admob 라이브러리 적용 시 버전 문제

XCode의 콘솔창에 다음과 같은 메시지가 계속 뜨고 있었다.

<Google:HTML> Google Mobile Ads SDK: You are currently using 6.5.1 of the SDK. A new version, 6.9.2, is available at http://goo.gl/Zc0BYt . Please consider updating your SDK to get the latest features and bug fixes

문제는 최신 버전 SDK를 받아서 설치하였는데도 계속 뜨는 것이었다.

누군가가 라이브러리 참조 위치를 확인해보라 해서 혹시나 하고
빌드 설정을 봤더니 중간에 예전프로젝트의 디렉토리를 참조하고 있었다.
(Build Settings - Library Search Path)

거기엔 구 버전(6.5.1)의 라이브러리가 깔려있었고..

더이상 해당 디렉토리를 참조하지 않도록 삭제를 했더니 더이상 위와 같은 경고가 뜨지 않음.


애드몹 뿐만 아니라 다른 라이브러리 쓸 때도 한번 쯤은 확인해 봐야 혼란을 막을 수 있을 것임.

2014년 4월 7일 월요일

[iOS] UIAlertView 사용하기

UIAlertView 간단한 사용 예제


UIAlertView는 UIAlertVIewDelegate 프로토콜을 따른다.
(헤더파일에 <UIAlertViewDelegate>를 포함시키지 않아도 작동된다.)
#1
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Question"
                                                       message:@"Do you want to build a snowman?"
                                                      delegate:self
                                             cancelButtonTitle:@"NO"    /* nil 로 지정할 경우 cancel button 없음 */
                                             otherButtonTitles:@"YES", nil];

    // alert창을 띄우는 method는 show이다.
    [alert show];



#2
// UIAlertView의 delegate method이다
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    // OK 버튼을 눌렀을 때 버튼Index가 1로 들어감
    if (buttonIndex == 1) {
        NSLog(@"Clicked YES");
    }
    else {
       
    }
}


예제 실행 화면



* 만약 하나의 ViewController 안에 alertview를 여러 개 사용해야 한다면
다음과 같이 각각의 alertview에 tag를 지정해주어 식별해야 한다.

alertA.tag = 101;
alertB.tag = 102;

...

// UIAlertView의 delegate method
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if ( alertView.tag == 101 ) {
       if (buttonIndex == 1) {
            NSLog(@"Alert A - YES");
        }
    }
    else if ( alertView.tag == 102 ) {   
       if (buttonIndex == 1) {
            NSLog(@"Alert B - YES");
        }
    }
    
}


<Result>

alertA 호출 + YES버튼 터치 시 :
  2014-04-08 15:48:50.902 AlertViewTest[3098:60b] Alert A - YES

alertB 호출 + YES버튼 터치 시 :
  2014-04-08 15:53:22.981 AlertViewTest[3106:60b] Alert B - YES

2014년 1월 18일 토요일

Implement lazy loading on iOS

UITableView에서 인터넷으로 이미지 로딩 시 쓰는 기법.

예제 링크:

싱크 문제점 발생 시:

JSON Data를 NSMutableDictionary로 받기

JSON data를 받은 MutableDictionary에서 value/key를 하나 추가하려니
immutable object를 건드리려 했다고 에러가 발생했다.

- 다음과 같이 해결 -

NSUInteger readingOptions = NSJSONReadingAllowFragments | NSJSONReadingMutableContainers;

위 변수를 [NSJSONSerialization JSONObjectWithData: options: error:] 의 options: 파라미터로 넘겨준다.