Reputation:
I've an UITabBarController. In my UIViewController a UItextView where I can select the text but when I change the View, text is kept selected. I've tried to add that code but doesn't work:
var range:NSRange = textView.selectedRange
range.length = 0
range.location = NSNotFound
Upvotes: 1
Views: 1620
Reputation: 578
Did you try setting textView.selectedTextRange = nil
?
Edit: Depending on your requirements, could you set this in viewWillDisappear
or viewWillAppear
so it is deselected when you either leave or come back to your view controller?
Similar to: How do I deselect text in UITextView?
Upvotes: 1