0

I have an iOS application that looks up employees and shows their work number/mobile number. The problem I am having is after looking up one person and then another, when I click on the number of the person I just looked up, it keeps calling the number of the previously searched person.

And before anyone says anything, I have looked at UITextView link detection in iOS 7

I have tried setting the textview.text = nil, disabling and enabling selectable, editable and scrollEnabled. Nothing has worked. If anyone could please shed some light on the problem I am having, that would be great. Thank you!

  1. Lookup 1st employee, click on phone# and it calls correct number
  2. Lookup another employee (2nd employee), shows correct phone#, click on phone# and it calls 1st employee's phone#
  3. Lookup another employee (3rd employee), shows correct phone#, click on phone# and it still calls 1st employees phone#.

the UITextView has selectable = true, detection = phone numbers, editable = NO, have tried setting scroll enabled = YES and NO.

iOS Deployment target is 7.0

Code:

@property (weak,nonatomic) IBOutlet UITextView *Phone;

found = [happyArray valueForKey:@Extension"];
if ([found length]>0) _Phone.text = [NSString stringWithFormat:@"%@",[found stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]]];
Community
  • 1
  • 1
  • Your question and your issue is not clear. Are you saying that you display some text that happens to have a phone number in a text view and if you click the phone link, the proper number is called. But if you then update the same text view with different text with a different number, tapping link calls the previous phone number? Show your relevant code. – rmaddy Aug 04 '14 at 18:22
  • Please update your question with the additional details do it is easer to read. – rmaddy Aug 04 '14 at 18:31
  • done, let me know if you need to see more of the code – tickleburnt Aug 04 '14 at 18:37
  • Have you set a break point to see that when you select a person its really who you meant to select. – logixologist Aug 04 '14 at 18:46
  • I'm still waiting on getting access to a repository so I can actually try some break points out, but when I lookup another person and it displays the correct information, doesn't that mean I have selected the correct person? – tickleburnt Aug 04 '14 at 18:49

1 Answers1

1

This appears to be an iOS bug, like it mentions in this other answer of SO. Try setting the text view to editable and then unsetting it just after setting the new number.

If that doesnt work, use setText:nil before setting the number again.

Community
  • 1
  • 1
rr1g0
  • 383
  • 4
  • 13
  • oh yeah... apparently I had the same problem because I have seen that post before. – logixologist Aug 04 '14 at 19:12
  • Thank you, it seems to work now. I had tried setting and unsetting the editable before, but I tried that as the same time as setting the text to nil along with selectable and scrollable. But setting and unsetting editable just by itself seemed to do the trick. – tickleburnt Aug 04 '14 at 19:19