UIWebView에서 내부 웹페이지의 크기를 알고 싶을 때.


- 해당 웹뷰 객체 내부의 scrollView를 이용하면 됨.


  예. webView.scrollView.contentSize.width

       webView.scrollView.contentSize.height


  참고. 해당  scrollView의 속성은 readonly 임.

Posted by 프리지크
:

UIWebView에서 불려진 웹 페이지에 확대/축소 기능을 넣기


  - scalesPageToFit 을 YES로 설정해준다.


끝.

Posted by 프리지크
:

XCode에서 클래스 등을 만들기 위해 파일을 새로 만들면 상단에 아래와 같은 주석이 기본으로 만들어진다.


//  

// TestViewController.m

// TestProject

//

// Created by reddolphin on 13. 12. 5

// Copyright (c) 2012 __MycompanyName__. All rights reserved.

//


최근 Doxygen Document를 만들기 위해서 주석문의 포맷을 변경할 필요가 있었다.

파일을 만들고 위의 기본 형식을 Doxygen document으로 바꿔줄려니 매번 번거롭게 해 줘야 해서 이 참에 기본 포멧을 바꿔줬다.


기본 포멧을 바꿔줄려면 "__FILEBASENAME__.h"와 "__FILEBASENAME__.m"을 바꿔줘야 한다.

이 둘의 위치는 아래 순서로 찾을 수 있다.


1. Finder > Application 에서 XCode의 '패키지 내용 보기'를 해서 아래 경로까지 들어가보면 설정 파일들이 있다.


  1) 패키지 내용 보기 (현재 iMac에는 Xcode 5와 Xcode4.6.3이 같이 설치되어 있기에 두개가 보인다. 난 Xcode 4.6.3만 수정할 거다.)


  2) 아래 경로 우측을 보면 iPhoneOS와 MacOSX가 있는데, 난 iPhone을 개발하고 있음으로 iPhoneOS 선택.


  3) 좀 더 들어간다.


  * 전체 경로를 보자면 아래와 같다. 

    /Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneOS.platform

/Developer/Library/Xcode/Templates/File Templates/Cocoa Touch


  4) 해당 경로 아래에 있는 __FILEBASENAME__.m/.h에 있는 내용을 doxygen document를 위해 아래와 같이 수정하였다. 


/**

 * ___PROJECTNAME___

 *

 * @file   ___FILENAME___

 * @brief

 * @Created by ___FULLUSERNAME___ on ___DATE___.

 *

 * ___COPYRIGHT___

 */ 


  그런데, 하위 폴더들을 보면 각 클래스의 종류에 따라 __FILEBASENAME__.m/.h 가 무지 많다.

  ('난 시간 많은 사람~.'이라면 하나하나 다 바꿔줘도 된다. )


2. 참고하다보니 Sublime Text 2라는 멋진 에디터가 있더라. 이 에디터로 해당 디렉토리 밑에 있는 파일들에서 일치하는 부분을 한번에 바꿔줄 수 있다.

  1) 우선 Sublime Text 2가 없으면 설치해준다. (유료다. 비싸다. 그런데 사용은 할 수 있다.)

      URL : http://www.sublimetext.com/


  2) Find > Find in Files 를 선택한다.


  3) 아래 부분에 관련 정보를 넣고 Find를 하면 찾아진 부분과 파일들을 보여주는데, 한번 확인 한 뒤에 Replace를 해서 주석문을 교환해주었다. 

     - Find : 찾고자하는 문자열

     - Where : 대상 폴더 지정. 

                    나는 XCode 4.6.3에 있는 부분만 바꿔주기 위해서 위에 찾은 경로를 그대로 넣었다.

 ( /Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneOS.platform

/Developer/Library/Xcode/Templates/File Templates/Cocoa Touch )

     - Replace : 새로운 문자열. 


   * 참고로 경로는 아래와 같이 알 수 있다.


  4) 아래와 같이 검색 결과가 나왔다.


  5) Replace를 하고 나니 수정이 되었다.


  6) 그리고, 프로젝트에 새로운 파일을 생성해보니 잘 만들어진다. 그런데, Copyright 앞에 공백이 들어가 있다. 왜지. ㅠㅠ 다시 만들어야겠다.



- 참고 : http://unlimitedpower.tistory.com/66

Posted by 프리지크
:

컴퓨터 공학에서의 여러 알고리즘들. 사용할 일이 자주 있지는 않지만, 그래서 잊어버리기 쉬운 것들이라 가끔씩 되새겨줘야한다. 기초는 언제나 튼튼하게. 


EKAlgorithms ( https://github.com/EvgenyKarkan/EKAlgorithms )

Array

  1. Index of maximum element in array.
  2. Find longest string in array of strings.
  3. Find shortest string in array of strings.
  4. Array reverse.
  5. Intersection of two arrays.
  6. Union of two arrays (with remove duplicates).
  7. Find duplicates.
  8. Array with N unique/not unique random objects.

Search

  1. Linear search.
  2. Binary search.

Sort

  1. Bubble sort.
  2. Shell sort.
  3. Merge sort.
  4. Quick sort.
  5. Insertion sort.
  6. Selection sort.
  7. Heap sort.

String

  1. Palindrome or not.
  2. String reverse.
  3. Words count.
  4. Permutations of string.
  5. Occurrences of each character (a - z).
  6. Count "needles" in a "haystack".
  7. Random string.
  8. Concatenation of two strings.
  9. Find 1st occurrence of "needle" in a "haystack".
  10. Last occurrence of "needle" in a "haystack".

Number

  1. Sieve of Eratosthenes.
  2. Great common divisor (GCD).
  3. Least common multiple (LCM).
  4. Factorial.
  5. Fibonacci numbers.
  6. Sum of digits.
  7. Binary to decimal conversion.
  8. Decimal to binary conversion.
  9. Fast exponentiation.
  10. Number reverse.
  11. Even/odd check.
  12. Leap year check.
  13. Armstrong number check.
  14. Prime number check.
  15. Swap the value of two NSInteger pointers.

Data structures

  1. Stack (LIFO).
  2. Queue (FIFO).
  3. Deque.
  4. Linked list.
  5. Graph
    • DFS (depth-first search);
    • BFS (breadth-first search).
  6. Binary search tree (BST).


Posted by 프리지크
:

iOS에서 Push Notification을 받았을 때 처리하는 방법은 크게 3가지가 있다.


1) 실행 중이 아닌 상태에서 노티를 받았을 때,

    application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 에서 처리.

   

2) 실행 중이며 Foreground 상태 일 때, 

application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo


3) 실행 중이며 Background 상태 일 때, 

application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo


각각의 예를 보자면, 

1)번의 경우, 최초에 한번 실행되는 didFinishLaunchingWithOptions에서 처리.
   예)  

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

   NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];


    if(userInfo != nil)

    {

        [self application:application didReceiveRemoteNotification:userInfo];

    }

 

    // ....

}


2), 3)번의 경우에서 Foreground와 Background의 상태에 따라서 처리를 다르게 할려면 UIApplicationState를 이용하면 된다.


typedef NS_ENUM(NSInteger, UIApplicationState) {

    UIApplicationStateActive,               // Foreground 상태에서 앱이 실행되고 있을 때.   

    UIApplicationStateInactive,             // Background 등의 상태에서 Foreground 상태로 바뀔 때.

    UIApplicationStateBackground        // Background 상태에서 실행 될 때.

} NS_ENUM_AVAILABLE_IOS(4_0);


예)

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 

{

    

    if (application.applicationState == UIApplicationStateActive)

    {

        // ....

    }

    else 

    {

        // ....

    }

}



------------------

참고

 - http://situee.blogspot.kr/2013/08/ios-handle-remote-push-notification.html   - https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/econst/UIApplicationStateInactive

Posted by 프리지크
:

언제부터 바꼈는지는 모르겠지만, 구글 애드샌스 1단계 가입신청과 2단계로 사이트에 광고영역을 넣은 이후에야 승인이 나고 해당 영역에서 광고가 노출된다.

대부분의 설명들이 1단계 계정생성하고 승인 메일을 받은 다음 2단계로 광고를 만들면서 진행하면 된다는데, 신청을 하고 며칠을 기다렸는데도 승인메일이 오지 않았다. 여기저기 찾던 와중에 2단계까지 진행을 해야 승인이 난다는 내용을 보고 빈 화면의 광고를 걸어두니 이틀만에 승인 메일이 왔다.

한참을 이 상태로 보냈다. ㅡㅡ;;; 2단계로 광고 생성 후 빈광고를 넣고 나니 승인 메일이 오더라. 



Posted by 프리지크
:

iOS6에서 UITableViewCell 위에 올라간 UILabel, UIButton 등의 객체를 참조할 때의 코드가 iOS7에서 조금 변경되었다.

- iOS6

    UITableViewCell

      ↳  UITableViewCellContentView

           ↳ UILabel ...


- iOS7

    UITableViewCell

      ↳ UITableViewCellScrollView  <- 추가됨.

           ↳ UILabel...

           ↳ UITableViewCellContentView

                ↳ UILabel ...


그래서 iOS6에서 Cell 아래에 있는 Label등에 접근할 때, 또는 Cell 위에 아래와 같이 버튼을 올렸을 경우

  UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];      

  [button3 setFrame:CGRectMake(145100113)];         

  [button3 addTarget:self action:@selector(cellButtonAction:) 

     forControlEvents:UIControlEventTouchUpInside];

  [cell.contentView addSubview:button3];


- iOS6까지는 아래와 같이 접근이 가능했음.

        UITableViewCell *cell = (UITableViewCell *)[[(UIView *) sender superviewsuperview];

    UITableView *tableView = (UITableView *)[cell superview];

    NSIndexPath *cellIndexPath = [tableView indexPathForCell:cell];

    NSUInteger row = [cellIndexPath row];


- iOS7 에서는 Cell과 ContentView 사이에 UITableViewCellScrollView 가 추가되고, 

UITableView와 Cell 사이에 UITableViewWrapperView가 추가되었다. 그래서 접근하기 위해서는 superview가 더 필요하다.

    UITableViewCell *cell = (UITableViewCell *)[[[(UIView *) sender superviewsuperviewsuperview];

    UITableView *tableView = (UITableView *)[[cell superviewsuperview];

    NSIndexPath *cellIndexPath = [tableView indexPathForCell:cell];

    NSUInteger row = [cellIndexPath row];


UITableViewCellScrollView?

  - UITableViewCell에 추가된 Private Class.

  - iOS7에서 Cell을 삭제할 때 왼쪽으로 스크롤해야하는데, 이 때 사용되는 것으로 보임.


UITableViewWrapperView? 

  - Private Class 같은데, 용도를 아직 모르겠음. 

--------------------------

추가사항. 

위에서 예로 든 경우 superview를 이용해서 접근하고 있는데, 아래와 같은 방법으로 이용하는게 좀 더 안전한 방법임을 다른 분이 알려줌.


- (void)btnPressed:(id)sender

{

   CGPoint btnPos = [sender convertPoint:CGPointZero toView:tableView];

   NSIndexPath *ip = [tableView indexPathForRowAtPoint:btnPos];

   if (ip != nil) {

      ...

   }

}


Posted by 프리지크
:

XCode 단축키.

2013. 9. 26. 09:52

(* 참고 : 아이폰과 맥 OSX 개발을 위한 Objective-C 2.0, Apress)


Command + [

코드 블록을 왼쪽으로 쉬프트.

Command + ]

코드 블록을 오른쪽으로 쉬프트.

Tab

코드를 완성한다.

Esc

코드 완성 메뉴를 보여준다.

Control + . (마침표키)

코드 완성에서 알맞은 다음 코드를 보여준다.

Shift + Control + . (마침표키)

코드 완성에서 알맞은 이전 코드를 보여준다.

Control + /

코드 완성에서 다음 입력 영역으로 이동한다.

Command + Control + S

스냅 샷을 만든다.

Control + F

커서를 앞으로 이동한다.

Control + B

커서를 뒤로 이동한다.

Control + P

커서를 이전 라인으로 이동한다.

Control + N

커서를 다음 라인으로 이동한다.

Control + A

커서를 라인의 시작으로 이동한다.

Control + E

커서를 라인의 끝으로 이동한다.

Control + T

커서에 인접한 문자를 바꾼다.

Control + D

커서에 인접한 문자를 지운다.

Control + K

라인을 지운다.

Control + L

커서를 텍스트 에디터의 가운데로 보낸다.

Option + 더블클릭

문서를 찾는다.


Posted by 프리지크
:

XCode에서 가끔씩 업그래이드 후에 프로젝트를 열 경우 Syntax Color가 풀려있는 경우가 있음.


1. Menu Window > Organizer > Projects 에서 해당 프로젝트 선택 > Derived Data를 Delete 시켜주기 > XCode restart.


그래도 안되면,

2. Product > Clean > Build 시켜주기.


Posted by 프리지크
:

어느분이 Peter Cottle의 LearnGitBranching 글을 번역해서 데모를 볼 수 있게 만든 사이트. 멋지네.

감사의 인사말씀을~ 

URL : http://learnbranch.urigit.com/



Posted by 프리지크
:

BLOG main image
인생에서는 찾고, 노력하고, 희생할 각오가 되어 있는 것만 얻을 수 있다. (조시 매슈 애덤스) by 프리지크

공지사항

카테고리

분류 전체보기 (121)
끄적끄적 (16)
좋은 글 (9)
자료 (19)
런닝&피트니스 (18)
기술 (43)
기사 스크랩 (1)
내가 본 공연 후기 (1)
내가 가 본 맛집 (5)
괜찮아 보이는 펜션들 (4)
(4)
한장한장 (0)
비공개 스크랩 (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :