본문 바로가기

iPhone dev.

In-app purchase 정리 *iTunesConnect가 변경되었기 때문에 사용자를 추가할 때 단순히 tester를 추가하는 것이아니라 sandbox tester로 추가해야 됨 link: http://stackoverflow.com/questions/19556336/how-do-you-add-an-in-app-purchase-to-an-ios-application How do you add an in-app purchase to an iOS application?up vote46down votefavorite66How do you add an in-app purchase to an iOS app using XCode 5 or 6 using iOS 7 or 8? What are all the details and is there an.. 더보기
AVAssetExportSession 을 이용한 비디오 transcoding(stackoverflow) What is the best way to transcode a video in objective-c (iOS)?up vote3down votefavorite2I would like to, depending on the device and the settings in my application, transcode a video to a specific video format. For an example, if the user has an iPhone 4S and chooses medium settings in my application I would like to convert the video to 540p before I start processing. If he chooses high then I .. 더보기
Storyboards are unavailable on iOS 4.3 and prior Storyboards are unavailable on iOS 4.3 and prior위의 에러메시지를 보고 project deployment target을 5.0으로 변경하여도 위와 같은 오류가 계속 발생하는데, 문제는 project deployment target과 storyboard의 document versioning의 버전이 서로 맞지 않아서 발생하는듯 하다.해결책은 다음과 같다: 1. 프로젝트의 deployment target이 5.0 이상인지 확인한다.2. Storyboard 파일을 열어 속성 중 document versioning의 'Deployment':5.0, 'Development':Xcode 4.2 인지 확인한다. (target이 5.0인 경우)3. Xcode를 재실행한다. 더보기
UIImage 용량 줄이기 UIImage에 imageWithCGImage: scale: orientation: 이라는 함수가 있지만, scale로 크기만 조절할 수 있을 뿐, 이를 NSData로 옮겨도 용량은 그대로이다.그림의 실질적인 용량이 줄기위해선 UIGraphics... 함수로 image를 다시 그려야 한다.다음 예제 코드를 참고한다:(http://stackoverflow.com/questions/5012695/how-to-reduce-the-uiimage-size) UIImage *image = [actualImage you want to resize]; UIImage *tempImage = nil; CGSize targetSize = CGSizeMake(196,110); UIGraphicsBeginImageContext.. 더보기
아이패드 뷰 만들기(for universal app) 유니버셜 앱(Universal app)을 만들기 위해 아이폰과 아이패드 각각의 뷰가 필요한 경우가 있다.앱이 아이폰/아이패드의 클래스를 공유하고 UI만 다르게 하고 싶다면 다음과 같이 설정하면 된다. 1. 기존 아이폰 view의 이름을 MyView.xib라고 하면, 프로젝트에 MyView~ipad.xib라는 이름으로 View를 하나 추가한다. (메뉴에서 'File->New->File...'로 들어가 iOS 항목들 중 User Interface의 View를 선택하고 'Device Family'는 iPad로 선택한 후 파일명을 MyView~ipad.xib로 지정하면 된다.) 2. Xcode에서 MyView~ipad.xib를 선택하고 메뉴의 'View->Navigators->Show Navigators' 및 .. 더보기
UIImage 방향 바꾸기 사진을 찍고 앨범에 저장한 뒤에 그 사진을 어딘가로 전송하는 것엔 문제가 없지만, 찍은 후 저장하지 않고 바로 NSData 형식으로 서버에 전송하면 사진이 찍힌 orientation에 따라 방향이 바뀌어 전송된다.이를 해결하기 위해서는 UIImage로 저장된 그림의 .imageOrientation에 따라 그림을 돌려주면 된다: // 방향 바꾸기 CGAffineTransform transform = CGAffineTransformIdentity; switch (takenImage.imageOrientation) { // UIImage *takenImage는 해당되는 그림 case UIImageOrientationDown: case UIImageOrientationDownMirrored: transform .. 더보기
UIScrollView 내부의 버튼이 동작 안 할 때 UIScrollView에 UIGestureRecognizer(혹은 UITapGestureRecognizer 등)를 추가한 상태에서 그 안에 UIButton을 넣은 경우 UIButton이 작동하지 않는 경우가 있다.iOS 5.1 이상에서는 문제 없이 작동하나, iOS 5 이하에서는 작동을 안 하는 것 같다.이럴 땐 UIScrollView에 추가된 gestureRecognizer의 설정을 다음과 같이 바꿔준다. ... [scrollTapRecognizer setCancelsTouchesInView:NO]; // default 값이 YES인 경우가 있다.... 더보기
UITabbar 이미지로 채우기 (텍스트 삭제) 다음과 같이 UITabbar에 텍스트가 아닌 그림으로 꽉 채우고 싶은 경우가 있다. 이 땐 다음과 같이 Interface builder(혹은 코드)에서 inset을 음수로 조절해주면 텍스트가 아래로 밀려나 그림이 전체를 채우는 효과를 보일 수 있다. 더보기
아이폰 빈 공간(사용량) 구하기 아이폰의 free space를 프로그램으로 구하려면 다음의 함수를 사용한다: - (uint64_t)freeDiskspace { uint64_t totalSpace = 0; uint64_t totalFreeSpace = 0; __autoreleasing NSError *error = nil; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error]; if (dictionar.. 더보기
UIButton 이미지 비율 조절하기 UIImageView의 경우 UIViewContentMode를 interface builder(IB)에서 조절할 수 있다.(Scale to fit, Aspect fit, Aspect fill, ...)하지만, UIButton에 이미지를 적용했을 경우 IB에서는 버튼 view 자체의 UIViewContentMode만 변경할 수 있는데, 코드로 다음과 같이 변경하면 된다. UIButton *button = [[UIButton ...]];[button.imageView setContentMode:UIViewContentModeScaleAspectFit] 위의 예제는 버튼의 이미지 모드를 Aspect fit으로 변경한 경우이다. 더보기