 |
 |
|
 |
07-09-2009, 11:18 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Posts: 52
|
Loading local .js file into uiwebview problem
I have a local .html, . js and images files in my bundle.
using this code
Code:
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"filename" ofType:@"html" inDirectory:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
I am loading html file into uiwebview. Local pictures are showing but . js files are not being loaded so i can't use functions inside them..
tried to insert <a href="file. js">show js file</a> into html. link leads to nothing.
Any help?
10x
|
|
|
07-09-2009, 11:28 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Posts: 52
|
I just noticed that i am getting warnings about . js files
warning: no rule to process file '$(PROJECT_DIR)/CanvasGraph. js' of type sourcecode.javascript for architecture i386
Maybe I need set some rule in Xcode for js files??
If yes, what should i do?
Quote:
Originally Posted by romeos28
I have a local .html, . js and images files in my bundle.
using this code
Code:
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"filename" ofType:@"html" inDirectory:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
I am loading html file into uiwebview. Local pictures are showing but . js files are not being loaded so i can't use functions inside them..
tried to insert <a href="file. js">show js file</a> into html. link leads to nothing.
Any help?
10x
|
|
|
|
07-09-2009, 11:33 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Posts: 52
|
solution
The problem is solved.
Solution is here
10x
Quote:
Originally Posted by romeos28
I just noticed that i am getting warnings about . js files
warning: no rule to process file '$(PROJECT_DIR)/CanvasGraph. js' of type sourcecode.javascript for architecture i386
Maybe I need set some rule in Xcode for js files??
If yes, what should i do?
|
|
|
|
07-09-2009, 11:43 AM
|
#4 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,569
|
Quote:
Originally Posted by romeos28
I just noticed that i am getting warnings about . js files
warning: no rule to process file '$(PROJECT_DIR)/CanvasGraph. js' of type sourcecode.javascript for architecture i386
Maybe I need set some rule in Xcode for js files??
If yes, what should i do?
|
It means XCODE doesn't know what to do with a . js file - compile it? link it? include it in the bundle unchanged? You want to include it in the bundle unchanged.
Look inside "Targets" in the the left pane, expand your target, and drag your file into "copy bundle resources." It should be added to the bundle the next time you build.
Maybe someone else knows how to add . js files to the list of files that get copied automatically?
__________________
|
|
|
11-08-2009, 07:53 AM
|
#5 (permalink)
|
|
Registered Member
Join Date: Oct 2009
Posts: 2
|
Quote:
Originally Posted by smasher
It means XCODE doesn't know what to do with a . js file - compile it? link it? include it in the bundle unchanged? You want to include it in the bundle unchanged.
Look inside "Targets" in the the left pane, expand your target, and drag your file into "copy bundle resources." It should be added to the bundle the next time you build.
Maybe someone else knows how to add . js files to the list of files that get copied automatically?
|
Hello I have the same problem and this doesn't work. Same error though.
|
|
|
11-08-2009, 10:26 AM
|
#6 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,569
|
Quote:
Originally Posted by johncoles
Hello I have the same problem and this doesn't work. Same error though.
|
Go the your build folder, right-click the built app, and choose "view contents" - you'll be able to tell if your . js file is being included in the bundle or not.
If the . js file is not in the bundle, it's still a build/target problem.
If the . js file is in the bundle, then either you're not including it properly in the html (notices it's not in a subfolder) or there's an error in your javascript - try dropping your html into safari and checking for errors.
PS - are you loading this javascript into a webview, or into mobile safari (openURL?)
__________________
|
|
|
11-08-2009, 05:12 PM
|
#7 (permalink)
|
|
Registered Member
Join Date: Oct 2009
Posts: 2
|
All sorted now
|
|
|
11-08-2009, 08:06 PM
|
#8 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,569
|
Quote:
Originally Posted by johncoles
All sorted now
|
What was it? Inquiring minds and all that.
__________________
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 449 |
| 42 members and 407 guests |
| AdyCoder, andluclive, appie, bensj, ChrisMayer, cmpak, Desdichado, develsolutions, dot, elninom, far100, fede, fiddy, FlukeDude, gbh, gomugroup, hm50, iphonig, javaconvert, jcww33, jsaarinen, Kalimba, Kilby, LemonMeringue, LightRoom, Locker, malaki1974, Mopedhead, oldmicah, preiss, ryguy2503, sayer, sennah, SimonHodgkiss, skunk, StefanL, stuffradio, tomoan74, ttthebest, wyoskibum |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,208
Threads: 38,991
Posts: 171,023
Top Poster: smasher (2,569)
|
| Welcome to our newest member, JDBurgie |
|