Skip to content

Commit

Permalink
Merge pull request #101 from nsolter/master
Browse files Browse the repository at this point in the history
fixes issue #69 - don't call willAddToken and didAddToken when token …
  • Loading branch information
thermogl committed Jul 20, 2015
2 parents 98773d4 + 4fd8632 commit 0615c6e
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions TITokenField.m
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ - (BOOL)becomeFirstResponder {

- (void)didBeginEditing {
if (_removesTokensOnEndEditing) {
[_tokens enumerateObjectsUsingBlock:^(TIToken * token, NSUInteger idx, BOOL *stop){[self addToken:token];}];
[_tokens enumerateObjectsUsingBlock:^(TIToken * token, NSUInteger idx, BOOL *stop){[self addTokenToView:token];}];
}
}

Expand Down Expand Up @@ -695,27 +695,30 @@ - (void)addToken:(TIToken *)token {
if (shouldAdd){

//[self becomeFirstResponder];

[token addTarget:self action:@selector(tokenTouchDown:) forControlEvents:UIControlEventTouchDown];
[token addTarget:self action:@selector(tokenTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:token];

if (![_tokens containsObject:token]) {
[_tokens addObject:token];
[self layoutTokensAnimated:YES];

if ([delegate respondsToSelector:@selector(tokenField:didAddToken:)]){
[delegate tokenField:self didAddToken:token];
}

[self showOrHidePlaceHolderLabel];
}
[self setResultsModeEnabled:NO];
[self deselectSelectedToken];

[self addTokenToView:token];

}
}

- (void) addTokenToView:(TIToken *)token
{
[token addTarget:self action:@selector(tokenTouchDown:) forControlEvents:UIControlEventTouchDown];
[token addTarget:self action:@selector(tokenTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:token];
[self layoutTokensAnimated:YES];
[self showOrHidePlaceHolderLabel];
[self setResultsModeEnabled:NO];
[self deselectSelectedToken];
}

- (void)removeToken:(TIToken *)token {

if (token == _selectedToken) [self deselectSelectedToken];
Expand Down

0 comments on commit 0615c6e

Please sign in to comment.