본문 바로가기

기술/iOS29

Storyboard에서 가로/세로의 UI가 다를 때 대응 방법. Storyboard 에서 iPad용 UI를 만들고 있는데, 가로/세로에 대해 서로 다른 UI를 만들어야 하는 경우가 생겼다. 문제는 iPad에서는 iPhone처럼 Regular/Compact을 조절해서는 안된다는 것.아래와 같이 해결했음. UITraitCollection을 이용해서 화면에 따라 모드를 지정해 준다. Storyboard 상에서는 아래 모드로 작업을 해두고세로를 작업할 때는 Width:Any, Height:Regular 로 하고,가로를 작업할 때는 Width:Regular, Height:Compact로 했음. RootViewController나 ParentViewController에 아래 코드를 추가하면 된다는데, 나는 NavigationController에 해 줬음. - (UITraitCo.. 2016. 6. 24.
Audio route 변경 시 Notification 수신 방법 * Audio route 변경 시 Notification 수신 방법. (예. Headphones plugged/unplugged) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(routeChanged:) name:AVAudioSessionRouteChangeNotification object:nil]; - (void)routeChanged:(NSNotification *)notification{ NSNumber *reason = [notification.userInfo objectForKey:AVAudioSessionRouteChangeReasonKey]; if ([reason unsignedIntegerValue] =.. 2016. 6. 10.
Headphone 이용 시 앱에서 이벤트 수신 방법. * Headphone 이용 시 이벤트 수신 방법. // Headphones의 played/paused event 수신. (예. Apple EarPods 일 경우, Center Button 한번 클릭) // !!특이점 // - Apple EarPods 일 경우, togglePlayPauseCommand를 수신. // - 일반 Bluetooth Headphones 일 경우, 아래의 playCommand/pauseCommand를 수신. (왜??? ;;;;) MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter]; [commandCenter.togglePlayPauseCommand addTarget:self action.. 2016. 6. 10.
NSString 특정 자리수만큼 문자열 분리하기. 예를 들어, 문자열을 4자리씩 끊어야 할 경우, NSString *number = @"1234567890"; NSError *error = NULL; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@".{1,4}" options:0 error:&error]; NSArray *matches = [regex matchesInString:number options:0 range:NSMakeRange(0, [number length])]; for (NSTextCheckingResult *match in matches) { NSLog(@"%@", [number substringWithRange:match.range]];.. 2015. 2. 27.
XCode 6 Simurator Keyboard에서 한글 나오도록 셋팅하기. XCode6 시뮬레이터에서 간혹(자주?) 한글 키보드가 안나오는 경우가 있다.아래 설정을 해 주면 나온다.그 전에 설정에서 키보드의 언어는 추가가 되어 있어야 한다. 2015. 2. 10.
XCode에서 메모리 영역 보기. 간혹 XCode의 디버그창에서 포인터로 된 변수의 경우 메모리에 직접 접근해서 값을 봐야하는 경우가 있습니다. 1. 우선 관련 라인에 브레이크 포인트가 지정된 상태에서 디버그 모드가 되어야합니다. 2. 원하는 변수에 대해 마우스 우클릭 또는 Ctrl+클릭을 하게 되면 옵션창이 뜹니다. View Memory of * 를 선택합니다. 3. 아래와 같이 메모리를 직접 볼 수 있는 화면이 뜹니다. 1) 현재 창에서 보이는 메모리의 주소를 지정할 수 있습니다. 2) 보이는 화면의 페이지 단위로 앞, 뒤 이동을 할 수 있습니다. 3) 창에서 보이는 Byte의 크기를 지정할 수 있습니다. 4) 바이트들을 묶음 단위로 볼 수 있습니다. 5) 확인 해 봤던 메모리의 위치들의 히스토리입니다. 참고 : https://dev.. 2014. 4. 9.