How to bundle non-version controlled images in Xcode's Resources folder? - ios

Here are the approaches we tried but did not work
Version control the images - bloats up our git repo, not a good idea
Images on DropBox - Whenever our designer adds an image on Dropbox it gets available to engineers, but the engineers then have to add the new image to their Resources manually.
Image folder on DB, link folder under Resources - Same as above, but we add the folder under Resources, not the image files. However, the manual process of adding newly added images still remain.
What are the best practices you have followed?

Have you tried adding a Folder Reference instead of a group when adding it to your project and using DropBox to keep that folder up to date with your images ?
As a Folder Reference, it should always reflect the current state of the linked folder without the need to manually add each file as it is downloaded from DB.
After running a quick test, I found that adding Folder References and trying to use the images from there with [UIImage imageNamed:#"fileName.png"] doesn't find the actual image.
You have to actually include the relative path to your Folder Reference, like this:
UIImage * imageFromFolderReference = [UIImage imageNamed:#"FolderReferenceName/fileName.png"];
That seemed to do the trick.

Related

Teamsisu/contao-greyify doesn't work in contao

I have download Teamsisu/contao-greyify and upload in vendor/ teamsisu folder.
Then give the inserttag
{{greyify::assets/images/9/Vicus-wint-iCMG-Enterprise-IT-Architecture-Excellence-Award-2016_banner-a428ab58.png/UUID?width=x&height=x&mode=x}}
But it doesn't work
Never use paths from the assets/images directory, since that is just the image cache. You need to reference the source image instead. You probably misinterpreted the README of the extension. You either use the path to the source image - or you provide the UUID of the file.
Example with image path
{{greyify::files/public/banner.png?width=200&height=100&mode=crop}}
Example with image UUID
{{greyify::c42739fa-39b8-11e9-b257-8c1645f08cc5?width=200}}

Appcelerator : ImageView and local files

for two days now, i have been looking for the correct place to put my local images and the correct way to access them in the Appcelerator platform (working with Alloy framework).
All i want to do is simply display a local image through an image view component. It works well with an image get from URL but seems impossible to get it from a local file.
this is an simple image view declaration in my index.js controller
/app/controllers/index.js. Where do i have to put my image to get this code working?
var img = Ti.UI.createImageView({
image:'images/DefaultIcon.png',
top:10,
width:100,
height:100
});
$.index.add(img);
I have read all the documentation about that issue and read a lot of similar questions over the internet. Anyway, none of the answers i've been reading bring me the correct solution.
No matter where i put my images into my project directory (assets folder, root folder, resource folder, image folder), those images seem to be not accessible !
I'm currently developing on iOS platform...
I really hope some of you guys have the solution ...!
Best regards,
Quentin
You need to put the images in the /app/assets/iphone/images folder.
Within that folder you can create as many folders as you'd like, the only thing you need to do is update the path accordingly.
So, you have an image with the name myIcon.png. Put this in /app/assets/iphone/images/myIcon.png (and don't forget to include #2x and #3x images in the same folder).
Then, in your imageView use this path /images/myIcon.png.
Want to put it in a folder? For example /app/assets/iphone/images/icons/myIcon.png then reference it in an imageview with /images/icons/myIcon.png.
For android you too need to use the images folder inside app/assets/android. But to specify dimension specific images you can put them in ldpi, mdpi,hdpi,xhdpi,xxhdpi and xxxhdpi folders as specified by Android

Using Backload to upload image to project file but images do not appear until project is rebuilt

Using MVC 4 I downloaded Blackcity Backload from nuget, I am trying to save the uploaded images to a file that is within my project. Everything works great and it shows that the image uploaded, except for the fact that after you upload a new image, and refresh the page the image does not appear in the list of returned images even though it was saved. Also if you delete a file it comes off the list at first but again if you refresh the page it is back. If you rebuild the application then everything appears as it should and the images in the backload file list are all listed correctly and they match what is in the actual file.
I thought it may be a server cache issue but I did all i can to prevent the server from caching and still same problem.
I think it may have to do with the fact that Backloader is dynamically creating folders to put the images in and they are not included in the project even though they are in the file structure. So since they are not part of the project they are not being returned in the get request. Its not until you rebuild that they are recognized as part of the project.
Is there a way to dynamically include new files in the project without rebuilding?
Please help. This is killing me.
Ok this is solved. Had to remove filters.Add(new AuthorizeAttribute()) from my global filters and then add [Authorize] to each controller and it worked.

How can I get all image names in asset catalog group?

In my app I had a folder of images from which I was getting the names to use as keys to a Dictionary. I have now moved all images to an asset catalog and created groups for the relevant folders. The code using FileManager is not working anymore as it can not find any folders (due to the assets being compiled into a .car file).
How should I approach this?
So (following matt's suggestion) here is what I did:
I created a RunScript build phase to run before compiling
and used a script to create a txt file with the names of the files that I can then use during runtime
#!/bin/sh
>./your_app_folder/fileNames.txt
for FILE in ./your_app_folder/Images.xcassets/actions/*; do
echo $FILE >> ./your_app_folder/fileNames.txt
done
You have two choices:
Don't Do That. Go right on using a folder of images.
Supply the keys in some other way. If you don't want to hard-code them into the code itself, you could make a text file. But of course you will have to keep that text file updated as you add / remove images.
You'll notice that I didn't say you could magically introspect the asset catalog. That's because you can't.

Updating iOS application content which include images

I am working on a Vegetable gardening application. Apart from the vegetable name and description I also have vegetable image. Currently, I have all the images in the Supported Files folder in the Xcode project.
But later on I want to update the application dynamically without having the user download a new version. When the user updates the application or downloads new data from the server that data will include the images. Can I store those images in the supporting file folder or somewhere where they can be references by just the name.
RELATED QUESTION:
I will also allow the user to take pictures of their vegetables and then write notes about the vegetables like "just planted", "about to harvest" etc. What is the recommended approach for storing pictures/photos. I can always store them in the user's photo library and then store the reference in the local database and then fetch and display the picture using the reference. The problem with that approach might be that if the user accidentally deletes the picture from the library then it will no longer be displayed in my application.
The only way I see if to store the picture in the app local database as a BLOB.
No you can't put the downloaded images with the others inside the supporting file folder. Also I would suggest you put the images inside an Images or Resources folder instead... If you want to download any data after the app is compiled, then they will not be in the bundle. It is the bundle you are referring to when talking about the Supported Files folder in Xcode. This is read only for your application.
Just to be clear, once compiled, there are no folder structures for your application, these "folders" are just groups in the Xcode project to keep things tidy.
If you download say a zip file containing a set of images, it's up to you to write them to disk after you download them. You should put these images in either the tmp, the cache or the documents directory.
But then you'll have to build your path before loading the images. You won't be able to just provide the name of the file such as:
[UIImage imageNamed:#"something.jpg"];
Because this will look in your bundle. Instead you must do something like this to load your image from the Documents directory for example.
Your challenge is that you will end up in a state where you'll have some images in the Bundle (the ones from when you uploaded your app), and the newer ones in the documents directory. You must them check the bundle first and if there is no image there, check the documents directory.
For user generated data, I suggest also saving the images in the Documents directory, and maintaining an SQLite database of the users data, so you can map an image name to an entry in the database. You don't want to save the images as BLOB because this will inevitably slow down the performance of your queries and add extra unnecessary load on the CPU to convert to UIImage and back.
You don't want to save their images to the gallery for 2 reasons, first this means you'll be saving in 2 places because keeping a reference in your database to an external image is very fragile and you're just asking for trouble, and secondly, once the image isn't under your wing, you don't control it anymore, the user will delete it at some point, if they go back to your app they expect to see it there.

Resources