2013-08-16 2 views

답변

1

구현 NSTokenField 위임 tokenField:shouldAddObjects:atIndex:

// return an array of represented objects you want to add. 
// If you want to reject the add, return an empty array. 

- (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index 
{ 
    if (index>2) { 
     return [NSArray array]; 
    } 
    NSLog(@"%@-- %d %d", tokens, [tokens count],index); 
    return tokens; 
} 
+0

[문서의 목적을 위해] 대답은 잘못 "인덱스"이 방법을 사용하여 tokenfield하지만 새 토큰의 삽입 위치에있는 토큰의 총 수없는 1 번째 또는 2 번째 위치에서 커서를 움직일 때만 원하는 토큰 수를 추가 할 수 있습니다. – Kappe