How to avoid hours being marked as link to calendar? - ios

I am using a UIWebView to fetch a webpage that contains the log of musics previous played at my radio station. The original file is here. It appears on the app as follows: Image
How can I force it to stay with the hours in white and do not create a link to the calendar?
Thanks in advance

Since you're loading it in a UIWebView you can turn off data detection for the UIWebView:
UIWebView *webView = // Set this up as you wish
webView.dataDetectorTypes = UIDataDetectorTypeNone;
This is all described in the UIWebView documentation

Related

Scroll To Specific Page using CGPDF

I am struck with this past two days i don't find any proper documents relating to CGPDF. I tried every possible way but i failed. Here is what i am trying to do. I have a PDF to display and i am displaying it in a UIWebView. I have created a CORE GRAPHICS PDF document reference using the path where the pdf is located (NSURL). I created a UIView over it and handled a single touch event. When the PDF loads and user clicks the view i want the page to scroll to a specific page. I know this can be done via calculating Page height and width. I wanted to know if there is a Way in CGPDF to pass a page number and it scroll to the relevant page. Below is my Code
- (void)viewDidLoad
{
[super viewDidLoad];
// set the pdfPafeHeight to -1 so it gets calculated.
self.pdfPageHeight = -1;
// set the delegate of the UIWebView's underlying UIScrollView to self.
self.webView.scrollView.delegate = self;
// create an NSURLRequest to load the PDF file included with the project
_filePath = [[NSBundle mainBundle] pathForResource:#"Sample" ofType:#"pdf"];
_url = [NSURL fileURLWithPath:_filePath isDirectory:NO];
_urlRequest = [NSURLRequest requestWithURL:_url];
// create a Core Graphics PDF Document ref using the same NSURL
_pdf = CGPDFDocumentCreateWithURL((CFURLRef) _url);
// use CGPDFDocumentGetNumberOfPages to get the number of pages in the document
self.pdfPageCount = (int)CGPDFDocumentGetNumberOfPages(_pdf);
// load the PDF file into the UIWebVie
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:#selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
[self.webView loadRequest:_urlRequest];
}
HERE IS HOW I WANTED HANDLE SINGLE TAP ON UIVIEW. I just wanted to know if there is any method in CGPDF to scroll to specific page when i pass a page number to it
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
}
There's no API for what you're trying to achieve, and even if you're able to use private API if this app is just for Enterprise install and doesn't need to go to the App Store - this will be tricky and any workaround will likely break with a major iOS version update. If you want to go this route, you can introspect the view controller hierarchy and will find that Apple internally has a framework called CorePDF which has an internal private API that you might be able to access - but be careful and know that this is not a solution for App Store apps.
The alternative is to start from scratch and use CGContextDrawPDFPage to draw PDF pages, building your own cache, scroll views and view controllers+gesture handling. We did that with the commercial PSPDFKit SDK which I work on since 2010 - it's more work than you'd think. We also eventually moved on and use a custom renderer to improve compatibility with the wide range of PDF files available and to offer a better performance than Apple's renderer, however not every use case might require this.

Update webview page number when updating font

I'm working on a book reader iOS application and using webview for displaying epub books. The 3rd party library I'm using for parsing epub book is "KFEpubKit".
I've to give option to user to adjust the font size (as in iBooks), and I've achieved that feature by updating the font of webview as:
let textSizeRule = "document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '\(fontPercentage)%'"
self.webView.stringByEvaluatingJavaScriptFromString(textSizeRule)
The problem I'm facing is that by increasing/decreasing font size, page number of book must also change. But I'm unable to do so.
How can I achieve this functionality in the way other book reading applications are doing it (i.e. kindle, iBook etc)?
You can create a second WebView object which is hidden. You do the same thing ("For time being, i'm reloading the book and computing page number.") in the background webview.
In your webViewDidFinishLoad method, check which webview is loaded
func webViewDidFinishLoad(webView: UIWebView) {
if webView == backgroundWebview {
//Compute number of pages
} else {
//Foreground webview
}
}
So the user is not disturbed by a reloading webview.
Hope this helps!

Custom info window for GMSMarker utilising UIWebView

I am using the Google Map iOS SDK for a project and have run into a problem whilst trying to implement a custom info window for a GMSMarker object. I have followed the Google video tutorial but instead of using A UILabel and UIImage, I am placing a UIWebView in the UIView as this will display HTML formatted text. However, when I run the code the UIWebView is always blank. If I replace with A UILabel the info window works. Has anyone else tried to use a UIWebView like this with the iOS SDK? I am wondering if it's related to the UIWebView taking too long to render?
last I checked the info window had to be a static uiview as it is rendered to an image. (same as markers are not UIViews but only static images)
the way I do it:
return an empty transparent view to the GMSMapView and THEN:
roll your own that you add as a subview yourself!
This link show what I described:
https://github.com/ryanmaxwell/GoogleMapsCalloutView

UIWebview taking too much of time to load html content in iOS 7

Uiwebview taking huge amount of time to load html content in iOS 7. The html content has mathjax library.
Its working good in iOS 5.1 and iOS 6.1.
Can you please help me how to fix this issue?
I am using loadRequest method to load html content into UIWebView.
Thanks,
Rahman
I have the same problem. After the update to iOS 7, the loadRequest takes about 10 seconds (with iOS 6 less than a second).
My code is like :
NSString *whichWiki = #"http://en.wikipedia.org/wiki/";
NSString *keyword = #"universe";
NSString *siteURLWiki =[NSString stringWithFormat:#"%#%#",whichWiki, keyword];
[webv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:siteURLWiki]]];
I tried 2 resolutions I found in Google:
self.webv.dataDetectorTypes = UIDataDetectorTypeNone; // Resolution 1
self.webv.suppressesIncrementalRendering = YES; // Resolution 2
but with results of no effects.
Strangely, I have this problem with URL of Wikipedia but NOT WITH URL of Google. I can get URLs of Google search results less than a second.
What's the difference between Wikipedia and Google ???
I unchecked the phone numbers detection on UIWebView from Storyboard. It works for me.

webViewDidFinishLoad did finish loading but didn't finish showing content on screen

I'm using webViewDidFinishLoad a lot in my app and there's something about UIWebView that really bugs me, well, actually two things.
The first, when I load new content to a UIWebView I will see for half a second the last page that was loaded to the same UIWebView what will force me to "clean" the UIWebView using something like:
[_mainWebView stringByEvaluatingJavaScriptFromString:#"document.open();document.close();"];
before loading the new content.
The second issue I have and that's the main issue for this question is that if i'll load some new content to my UIWebView and do something like this:
[_mainWebView loadHTMLString:htmlString baseURL:nil];
...
- (void)webViewDidFinishLoad:(UIWebView *)webView {
_mainWebView.alpha = 1;
}
In some cases the UIWebView will show up white for half a second before showing up the content. I'm guessing that the content is already loaded into the UIWebView and that's why webViewDidFinishLoad:webView is firing but for small html pages showing to content takes loner than the actual load. Is there any workaround I can use to avoid the blank screen that is showing for a sec or so but still save that second?
I thought about animating the alpha from 0 to 1 but that solution feels kinda lame to me.
Try adding a javascript callback so you know when the web view contents have actually loaded: Javascript in UIWebView callback to C/Objective-C

Resources