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

Toast-specific hidesOnTap Toggle #31

Closed
xanderdunn opened this issue May 2, 2014 · 2 comments
Closed

Toast-specific hidesOnTap Toggle #31

xanderdunn opened this issue May 2, 2014 · 2 comments

Comments

@xanderdunn
Copy link

I want some toasts in my app to respond to user taps and some to ignore user taps. Currently, the CSToastHidesOnTap is a global static const, so I don't think I can set it on a toast-by-toast basis, can I? I think I'll have to turn this into a UIView subclass and add a @property hidesOnTap.

I'm just checking that there isn't some use of the static const that I'm missing before I stray from the UIView category paradigm.

@scalessec
Copy link
Owner

Should be pretty easy to do in a fork. Here's how I'd do it:

Change the showToast:duration:position: method in UIView+Toast.m to something like this:

- (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)point hidesOnTap:(BOOL)hidesOnTap;

Then in the showToast:duration:position: method implementation, use hidesOnTap to add the gesture recognizer instead of CSToastHidesOnTap.

Then just update the makeToast constructors to include a hidesOnTap: parameter. Eg:

- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position title:(NSString *)title image:(UIImage *)image hidesOnTap:(BOOL)hidesOnTap;

i'm sure I missed a few things, but that should give you the idea. That should do the trick without needing to subclass.

@xanderdunn
Copy link
Author

Oh, thanks! Yeah, this works great. I didn't think of adding a method parameter because I forgot the hidesOnTap variable is needed on only one location so there's no need to store it.

@scalessec scalessec reopened this Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants