Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Passing an image to a new view

I'm attempting to create a Snapost-like app where a user can upload and image & text to a web service.

Unlike Snapost though, I'm creating different views and using the cooler 'slide' animation. My problem is passing the event.image created by the camera/photo gallery to a new view. I've tried creating a global var in the app.js file and storing the image in a property all to no avail.

I feel that the property approach is the better route, but I only see the ability to store strings not objects. Anyone have any idea how I could do this?

— asked March 29th 2010 by Christopher Webb
  • 0_o
  • image
  • iphone
  • mobile
  • property
  • variable
  • view
0 Comments

6 Answers

  • Accepted Answer

    Actually I thought of something like this:

    var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'tmp.jpg');
    f.write(this.responseData);
    Titanium.App.Properties.setString('myTmpImage', f.nativePath);
    
    — answered March 29th 2010 by S. Gazi
    permalink
    0 Comments
  • You could write the image into a file and pass the path if this is an option for you.

    — answered March 29th 2010 by S. Gazi
    permalink
    0 Comments
  • Then delete the file when done? If you don't mind, what would the code look like to do such a thing?

    — answered March 29th 2010 by Christopher Webb
    permalink
    0 Comments
  • I don't mind but I am not at my workstation. But have a look into the KitchenSink examples, xhr_remote_file.js or similar, you should find there the code your looking for.

    — answered March 29th 2010 by S. Gazi
    permalink
    0 Comments
  • So I've reviewed the Kitchen Sink examples, and they allow you to point to a file that you have in your file stack and save it to the photo gallery, but they don't have an example where you can get the path to the image saved on the phone's filesystem.

    Maybe the best solution is to just launch the camera/photo gallery on the page that I'd like to use it….that solves all of this doesn't it. I guess I'll just do that.

    Anyone with a better idea, please let me know.

    — answered March 29th 2010 by Christopher Webb
    permalink
    0 Comments
  • You're solution worked! Thanks!

    — answered March 29th 2010 by Christopher Webb
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.