Skip to content
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

Update SWCellButtonItem's image on tap #2

Open
andreamazz opened this issue Jul 16, 2014 · 6 comments
Open

Update SWCellButtonItem's image on tap #2

andreamazz opened this issue Jul 16, 2014 · 6 comments

Comments

@andreamazz
Copy link

Hi
First of all thanks for this library, it works just great.
I was wondering if there's a way to change the SWCellButtonItem's image within the handler of the item. Something along this lines:

    SWCellButtonItem *item = [SWCellButtonItem itemWithImage:[UIImage imageNamed:@"on"] handler:^(SWCellButtonItem *item, SWRevealTableViewCell *cell) {
        item.image = [UIImage imageNamed:@"off"];
    }];

I need to do this since my image is a toggle associated with the cell.
Is there any way to do so?
Thanks

@John-Lluch
Copy link
Owner

I am not sure if I understand your requirement. The handler is called when you tap on the button item, but at this time you should dismiss the revealing cell, so I am not sure if you want to replace the image at this time. Can you be more specific about what visual behavior you would want?
Thanks

@andreamazz
Copy link
Author

I'm using the right buttons as flags to vote an item up or down. I don't want to dismiss the cell (so that the user can change his vote without swiping the cell away a second time), but provide a visual feedback of the user's action (by switching the outlined up/down icon with a 'full' icon).

@andreamazz
Copy link
Author

This might help understanding what I mean:
http://d.pr/i/yPfh
(I currently implemented this with SWTableViewCell, but it breaks down with iOS8)

@John-Lluch
Copy link
Owner

Oh I see. I suppose this can be done by allowing setting item properties after they have been provided by the datasource. Currently, changing item properties only have an effect for the next revealing. I think UIBarITems update on screen by simply setting their image property, so I guess we could take a similar approach. Would that work?

@andreamazz
Copy link
Author

Yep, that would be great!
thanks

@maddoggy1979
Copy link

👍 for this enhancement - I am also keen to use this when it is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants