ios8 "sizeWithFont:" 사용 시 deprecated 나타날때 아래와 같이 변경하여 사용하면 된다.

CGSize size = [string sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17.0f]}];

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES && [[UIScreen mainScreen] scale] == 2.00) {
// RETINA DISPLAY
}

4inch 모델 (ihone5, 5s)에서 앱이 전체 영역을 활용하지 못 할때 처리 방법

참고 : http://useyourloaf.com/blog/2012/12/31/retina-4-support.html



"Default-568h@2x.png" 런처 이미지를 추가해 주면 된다.




"- (void)viewDidLoad"에서 "UIViewController"를 띄우려고 하면 아래와 같은 경고가 발생하며, 제대로 나오지 않는다.

 Warning: Attempt to present <PolarisViewController: 0x79656d00> on <ViewController: 0x7974f270> whose view is not in the window hierarchy!

뷰가 완성되지 않은 상태에서 띄우려고 하여 경고 발생.

"- (void)viewDidAppear:(BOOL)animated"에서 띄우면 정상동작한다.

- (void)viewDidAppear:(BOOL)animated

{

    //스토리보드의 ViewController 호출

    UIViewController* vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"];

    [self presentViewController:vc animated:YES completion:nil];

}


터치 좌표를 이용하여 각도구하는 방법

스크린 상단이 0도가 되며 좌측이 -, 우측이 + 스크린 하단이 180도 이다.


http://stackoverflow.com/questions/17037798/ios-detecting-line-angle-or-degree


- (float) getAngle:(CGPoint)a :(CGPoint)b

{

    int x = a.x;

    int y = a.y;

    float dx = b.x - x;

    float dy = b.y - y;

    CGFloat radians = atan2(-dx,dy);        // in radians

    CGFloat degrees = radians * 180 / 3.14; // in degrees

    return degrees;

}

NSDate *sourceDate = [NSDate dateWithTimeIntervalSinceNow:3600 * 24 * 60];

NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];

float timeZoneOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate] / 3600.0;

NSLog(@"sourceDate=%@ timeZoneOffset=%f", sourceDate, timeZoneOffset);



1. ARC 사용 유무 확인

  • 프로젝트 파일에 Build Settings에서 Objective-C Automatic Reference Counting (Yes / No) 확인

2. 소스파일 ARC  적용/해제

  • 프로젝트 파일에 Build Phases에서 Compile Sources탭의 .m 파일 선택
  • 선택한 소스 더블탭, ARC 사용할 경우 "-fobjc-arc", 사용하지 않을 경우 "-fno-objc-arc"


함수나 반복문 관련해서 처리되는 시간 측정이 필요한 경우가 있다.

방법은 다음과 같다.


NSDate* fsTime = [NSDate date];

for (...)

{

...

}

NSTimeInterval lsTime = -[fsTime timeIntervalSinceNow];

NSLog(@"%f sec", lsTime);

+ Recent posts