Skip to content

Commit

Permalink
fixes issue thermogl#69 - don't call willAddToken and didAddToken whe…
Browse files Browse the repository at this point in the history
…n token field begins editing
  • Loading branch information
Nicholas Solter committed Jul 19, 2015
1 parent 98773d4 commit 4fd8632
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 4fd8632

Please sign in to comment.