2013-08-16 57 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