I load html string in which i link a local css file that lies in docment folder,
...<head><link href="a.css">...</head>...
Then i call webview.loadHTML:htmlstring baseURL:docURL;
the css was loaded OK. Then I change the a.css 's body {background:url(b.gif);} //previous is a.gif, then I pop the webview's view controller, and re-push a new one in which the webview load the same html string that link same css but the body's background image has been changed. Now comes the problem: Some times the webview load the changed background, while some times it will load old image though the css changed! And maybe I realloc the view controller some times, it maybe load the right one!
Can anyone teach me how to fix it?
Thanks a lot!
Related
I have an app with a main.storyboard with a scene correctly set as the initial view controller. When I start the app and run it, this scene comes up as expected.
My problem occurs when I attempt to add custom fonts to the project. When I edit my info.plist to include the fonts in the Fonts provided by application section and then attempt to run the app, it remains stuck on the launch screen and the initial scene from the storyboard is never loaded. If I then remove the Fonts provided ... section from my info.plist file and run it again, the initial screen loads up as expected.
What am I doing wrong here? Does it matter where in the plist the entry is (like at the top or at the bottom)?
So, I discovered that my code was hanging/freezing completely when attempting to call CGFontCreateWithDataProvider (which is a necessary part of registering custom fonts). This was being called before anything else was loaded, so the freezing on this call was preventing the main screen from ever appearing.
The "fix" (gleaned from nearly-unrelated posts) was to add this line prior to the call(s) to CGFontCreateWithDataProvider:
UIFont.familyNames() // you don't need to iterate this array or do anything with it
No more hanging, app starts up as before and custom fonts all work properly.
I want to handle copy/select/selectAll/Patse options of UIResponderStandardEditActions in webview. but i am facing problem, the copy action never called and also i observed that , in function((I have webview where i am displaying text using TTStyledTextLabel)..
canPerformAction:(SEL)action withSender:(id)sender
The copy: action never comes..but i do see that all other options like select , selectAll and cut actions getting called, even though the copy action never called in above function when i select text in webview the copy action is enabled but action never gets called..
Have you solved your problem yet? If you did please post your solution. I'm having the same problem with the paste function.
The solution I found, and I know it's not ideal, its to detect the events through javascript.
I use javascript to detect when a paste happens, call my objectiveC function to work with the data, and call a JS function from the objectiveC to paste the content on the webview.
I have a few questions about a custom cursor in XNA, because I'm new.
I'm using:
cursorTex = Content.Load<Texture2D>("ico.png");
where cursorTex is a 2D Texture to load the cursor. However, it says file not found - even though it is in my Content directory. What's wrong and how do I fix this?
How can I set onMouseOver on certain buttons to react to change the cursor's image? And also, how do I change the image when the user is holding click?
Load the texture as
cursorTex = Content.Load<Texture2D>("ico");
instead of
cursorTex = Content.Load<Texture2D>("ico.png");
Edit: seeing you placed your file in a folder, just load it as ...<Texture2D>("other/ico");
I have a very large HTML Document that I need to show in my app. It utilizes CSS Columns, and scrolls horizontally. What I try to do is archive the UIWebView that renders the document in its current state, so that I can unarchive it from CoreData and don't have to let the user wait for a few seconds until it's rendered. So inside my UIWebViewDelegate, I serialize using the following method when webViewDidFinishLoad is called (the content is loaded from string, not from external sources):
[NSKeyedArchiver archivedDataWithRootObject:self.webView];
I checked if webViewDidFinishLoad is called multiple times, but it isn't. This and the core data saving actually works, i.e. it does save and load properly the next time the app is launched. However, while it saves the UIWebView itself, it seems like the content isn't loaded into it, which makes the whole procedure kinda useless for my purpose. Is my understanding of saving an object this way wrong, or is it simply a question of implementation?
Many thanks!
I dont think you should be archiving the UIWebview. Instead you can save the html document fil with custom CSS elements in the documents directory of the app and render it using the filepath using the following code.
self.webview.scalesPageToFit= YES;
[self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];
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