ios4 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. 이전 1 다음