2014-02-25 5 views
13

키만 사용하는 UIKeyCommand을 만들고 싶습니다. 지금까지 나는 시도했다 :return/enter 키를 사용하여 UIKeyCommand를 만들려면 어떻게해야합니까?

// These are pre-defined constants for use with the input property of UIKeyCommand objects. 
UIKIT_EXTERN NSString *const UIKeyInputUpArrow   NS_AVAILABLE_IOS(7_0); 
UIKIT_EXTERN NSString *const UIKeyInputDownArrow  NS_AVAILABLE_IOS(7_0); 
UIKIT_EXTERN NSString *const UIKeyInputLeftArrow  NS_AVAILABLE_IOS(7_0); 
UIKIT_EXTERN NSString *const UIKeyInputRightArrow  NS_AVAILABLE_IOS(7_0); 
UIKIT_EXTERN NSString *const UIKeyInputEscape   NS_AVAILABLE_IOS(7_0); 

인가 :

UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)]; 

은 아래, 왼쪽, 오른쪽, 그리고 (UIResponder.h에서) 탈출을 위해이 같은 키를 입력에 대한 글로벌 상수 없습니다 거기에 반환/캡처 키를 캡처 할 수있는 다른 방법이 있습니까?

답변

24

개행을 위해 @"\n" 대신에 캐리지 리턴으로 @"\r"을 사용해야합니다.

+0

'\ r'을 (를) '\ n'에 사용하고 싶을 것입니다. –