-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get value of attribute? #323
Comments
I believe the best way would be to unwrap the object and get the value directly. find(:face_image).get.remoteImage Not sure if that works, but give it a go. |
Hmm, it's been a long time, I don't remember. @GantMan added the remote image stuff in RedPotion. According to the docs (http://docs.redpotion.org/en/latest/cookbook/images/): To assign a remote image to a UIImageView: |
your suggestion failed with:
However unwrapping the object with get let me run :"url=:", I'll investigate a bit further and report back if one of these worked. |
Actually none of these work. Most return |
did you try Jamon's code? That looked right to me. Or maybe even
|
Hello. Yes I tried it and got the error I indicated:
with get! i get:
when I do
I get:
when running
I get hundreds of methods back, but the only
which leads me to believe it is only a setter and not a getter? I'm not really sure. I just ran against my Ruby knowledge limit. |
From a cursory glance you're right about setter. It looks like So you might be able to do I don't currently have a way to test this, so I'm coding blind, heh. Forgive me if the above is wrong, but it gives you a place to look. |
I'm running the code a few seconds after setting the image to make sure it is set. This is exactly why I require this functionality. Basically I need to start a countdown timer once a remote_image is actually shown (first I get the URL from an API and then I set the URL as a remote_image attribute), and I have no way of knowing when this exactly happens except by looking at the url set for the remote_image. Right now, I'm starting my timer 2 seconds after the call which is a horrible, potentially buggy hack. Using this: returns a UIImage object, and trying several of its methods, I'm still unable to get back the set remote_image url. However, it has got me thinking that maybe I really don't need the URL at all. I only need to know if the image has changed. Before setting the remote_image,
whereas 3 seconds later it returns: This means the image changed and I can start my timer. So I could use this to completely bypass this issue. Any idea how I can establish a callback or something that will let me know the image changed and trigger the timer? |
honestly, best to modify the source I linked and add an optional callback so you can do what you're looking for. At that same time you can even place an instance var for the image_url should you want to pave the way for anyone needing it. The PR would be accepted by @twerth if it is clean. |
I believe this would work. Thanks everyone for your help. I'll look into adding the callback and send the PR. |
Another option which might be simpler and more explicit is to manually fetch the image (using AFMotion or SDWebImage) and set it once it has been downloaded, then do whatever you want in your callback. |
Let me see if I understand correctly. My current flow is:
However there is a delay between setting the image with the code above and the image actually showing, so my countdown timer starts mismatched. Are you suggesting I can download the image via AFMotion / SDWebImage first and then set it locally? How would I go about this? I guess this would make the time mismatch nonexistent and solve my problem. |
Hi. I can't seem to figure this one out.
I am setting a remote_image for my UIImageView object like this:
find(:face_image).attr(remote_image: @face.picture)
it works fine.
However I can't seem to figure out a way to GET the value of the set attribute.
These all fail:
and when doing:
find(:face_image).data
I get back a UIImageView object back which does not respond to inspect.
Any hints?
The text was updated successfully, but these errors were encountered: