diff --git a/Classes/THContactPickerView.m b/Classes/THContactPickerView.m index bc52f21..e859e5a 100755 --- a/Classes/THContactPickerView.m +++ b/Classes/THContactPickerView.m @@ -173,6 +173,7 @@ - (void)addContact:(id)contact withName:(NSString *)name { if (self.selectedContactView){ // if there is a selected contact, deselect it [self.selectedContactView unSelect]; + self.selectedContactView = nil; [self selectTextView]; } @@ -283,6 +284,11 @@ - (void)removeContactView:(THContactView *)contactView { } [self removeContactByKey:contact]; + [self selectTextView]; + + if (self.selectedContactView == contactView) { + self.selectedContactView = nil; + } } - (void)removeContactByKey:(id)contactKey { @@ -295,7 +301,6 @@ - (void)removeContactByKey:(id)contactKey { [self.contactKeys removeObject:contactKey]; self.textField.text = @""; - [self selectTextView]; // update layout [self layoutContactViews]; @@ -506,6 +511,10 @@ - (void)contactViewWasSelected:(THContactView *)contactView { } - (void)contactViewWasUnSelected:(THContactView *)contactView { + if (self.selectedContactView == contactView){ + self.selectedContactView = nil; + } + [self selectTextView]; // transfer the text fromt he textField within the ContactView if there was any // ***This is important if the user starts to type when a contact view is selected diff --git a/Classes/THContactView.m b/Classes/THContactView.m index a928fab..d565545 100755 --- a/Classes/THContactView.m +++ b/Classes/THContactView.m @@ -188,6 +188,10 @@ - (void)select { } - (void)unSelect { + if ([self.delegate respondsToSelector:@selector(contactViewWasUnSelected:)]){ + [self.delegate contactViewWasUnSelected:self]; + } + CALayer *viewLayer = [self layer]; viewLayer.borderColor = self.style.borderColor.CGColor;