They added UIDataDetectorTypeAddress and UIDataDetectorTypeCalendarEvent to IOS 4.0
I'm assuming that UIDataDetectorTypeAddress creates links to the Map application.
What does UIDataDetectorTypeCalendarEvent create links for? Is it detecting an Event in the user's calendar, or is it just detecting da开发者_StackOverflow中文版tes, etc. I can't find any documentation on it.
I believe it will detect dates clicking on which should open the iPhone native calendar for you to add an event for that date.
Note: UIDataDetectorTypes won't work if your textView is editable.
You have to either set your textView to non-editable in the attributes of the textView if you are using the IB. Just select the textView and go to Tools->Attributes Inspector. Once there, uncheck the editable checkbox.
If you are adding your textView through code, then before adding the
textView.datadetectorTypes = UIDataDetectorTypeCalendarEvent
write this line of code
self.textView.editable = NO;
then you can specify the dataDetectorTypes
self.textView.dataDetectorTypes = UIDataDetectorTypeAll;
If you want to load some text in the textView then do this:
self.textView.text = @"www.Apple.com";
self.textView.editable = NO;
self.textView.dataDetectorTypes = UIDataDetectorTypeAll;
精彩评论