iOS 프로젝트에서 스토리보드를 제거하는 방법을 알아보자. 스토리보드가 있으면, 대형 프로젝트에서 여러사람이 협업시에 불편한점이 있고 수동으로 뷰를 컨트롤 하는게 명확하므로 제거하는 것이 좋다. 1. main.plist에서 "Main storyboard base file name"을 삭제해준다. 2. 기존 뷰 컨트롤러를 삭제해 준다. 예제에서는 ViewController.h/m이다. 3. 뷰 컨트롤러를 새로 생성한다. 생성하는 방법은 New file - iOS - Source - Cocoa Touch Class이다. 그리고 반드시 XIB를 생성하는 옵션을 선택하여야 한다. 4. AppDelegate.m에 다음과 같은 코드를 추가 한다. - (BOOL)application:(UIApplication *)a..
iOS 최신 버전에서는 [[UIDevice currentDevice]model]을 하여도 "iPhone"이라는 문자열 밖에 얻을 수 없다. 따라서 아래와 같이 구현하면 최신 iOS에서도 디바이스 모델 정보를 얻어올 수 있다. 다만 시뮬레이터에서 실행하면 x86_64가 얻어진다.(64비트 아이폰의 경우) #import // import it in your header or implementation file. NSString* deviceName() { struct utsname systemInfo; uname(&systemInfo); return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } @"i386" ..
// 선언 @interface RenderView : UIView { CADisplayLink *displayLink; } // 초기화 displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(runLoop)]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; // 루프함수 -(void)runLoop { NSLog(@"runLoop"); [self setNeedsDisplay]; }
iOS에서는 리눅스의 clock_gettime()함수가 존재하지 않는다. 따라서 리눅스 코드를 포팅할때는 아래와 같은 대체함수를 사용하여야 한다. #include #include #ifdef __MACH__ #include #include #endif struct timespec ts; #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time clock_serv_t cclock; mach_timespec_t mts; host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); clock_get_time(cclock, &mts); mach_port_deallocate(mach_..
#import @interface RenderView : UIView { CGImageRef imageRef; char *rawData; int rb, w, h; CGColorSpaceRef colorSpace; } @end #import "RenderView.h" @implementation RenderView - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; NSLog(@"initWithCoder"); colorSpace = CGColorSpaceCreateDeviceRGB(); w = self.bounds.size.width; h = self.bounds.size.height; rb = 4*w; NSLog..
내 앱의 뱃지 알림의 갯수를 런쳐쪽에 전달을 해주어야 런쳐에서 내 앱의 뱃지 갯수를 그려준다. 그래서 다음과 같이 앱에서 설정해 주어야 한다. public static String getLauncherClassName() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); PackageManager pm = AmandaApp.getAppContext().getPackageManager(); List resolveInfos = pm.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resolveInfos) { String ..
소스단위로 되어 있는 iOS 라이브러리를 프로젝트에 폴더단위로 드래그앤 드롭을 하게 되면 안에 있는 .a 라이브러리 파일들이 Build Settings에 Linked Frameworks and Libraries에 자동으로 추가가 되지 않는다. 따라서 항상 소스단위의 iOS 라이브러리를 프로젝트에 추가할때는 프로젝트의 폴더에서 오른쪽 버튼을 누른후 'Add Files to (ProjectName)'을 사용해야 한다.
- Total
- Today
- Yesterday