Tapping hyperlinked dates in UIWebView in iOS7 shows incorrect dates but not with iOS 6?

943 views Asked by At

In my iOS app, the operator enters a birthdate in a datePicker and then several new dates are created from the birthdate with NSDateFormatter of "EEEE, dd MMM yyyy". Using loadHTMLString, the new dates are loaded in a UIWebView. The "Event" property of the UIWebView is checked. In iOS 6, all new dates are shown with hyperlinks and when tapped and the "Create Event" is selected, the correct page of the calendar is opened and there is no error in the debugger output. In iOS 7, the new dates are shown with hyperlinks in the UIWebView but when tapped, the "Create Event" option shows a totally different date from what is shown on the UIWebView. In addition, in iOS 7, some of hyperlinked dates when tapped, a very odd error appears in the debugger output that I can not find it anywhere on the web. Here is the error:

Unknown DDResult category 1 for result ; could not find any actions for URL x-apple-data-detectors://1

Has anyone seen the above error before?

Here are the screenshots of the app demonstrating the dates before and after being tapped:

screenshot1 Screenshot1 shows several dates before being tapped. The hyperlinked dates point to the upcoming (future) dates.

screenshot2 Screenshot2 is taken after the date 10 Feb 2014 was tapped and the "Create Event" option was selected from the pop-up event view controller. As you see the wrong date (14 Oct 2013) is opened in the calendar instead of 10 Feb 2014.

Any idea why the incorrect dates are shown in the calendar with iOS7 but not with iOS6?

1

There are 1 answers

0
htahmas On

This is the workaround to resolve the issue with UIWebView in iOS7:

1) turning off data detector for the UIWebView

     myWebView.dataDetectorTypes = 0;

2) forcing the web view to load a dummy page

    [myWebView loadHTMLString:@"<html><p>clear</p></html>" baseURL:nil];

3) some code here to do all the calculations to create new dates and convert them to a HTML string (myHTMLString) and then re-enable the event data detector for the UIWebView

    myWebView.dataDetectorTypes = UIDataDetectorTypeCalendarEvent;

4) Now load the UIWebView with the html string which contains the new dates:

   [myWebView loadHTMLString:myHTMLString baseURL:nil];

The above solution solved my problem.