简体   繁体   中英

Using native images in Cordova

I want to use custom images for tab bar icons, as set in this line using this extension: https://github.com/squerb/cordova-ios-tab-bar (imageName is passed through the extension from the javascript):

item = [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed: imageName] tag:tag];

I'm struggling to work out where I need to put the image in my Cordova project so that it's accessible by the native code. If indeed that's possible.

I've tried this:

item = [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:@"www/assets/failed.png"] tag:tag];

But that results in this error:

2016-02-01 15:52:02.894 MovidiamWeb[2527:1070985] -[NSNull length]: unrecognized selector sent to instance 0x1a1e33ea8
2016-02-01 15:52:02.897 MovidiamWeb[2527:1070985] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> -[NSNull length]: unrecognized selector sent to instance 0x1a1e33ea8

第二种形式,引用了xcode项目目录中可见的路径,在cordova的情况下,“ www / images / whatever.png”应该可以正常工作,只是出于某种原因在开始工作之前只需要给它一些提示即可。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM