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

Modifications for iOS 6 (minor) plus added tap support #2

Closed
anthonydesouza opened this issue Nov 29, 2012 · 0 comments
Closed

Modifications for iOS 6 (minor) plus added tap support #2

anthonydesouza opened this issue Nov 29, 2012 · 0 comments

Comments

@anthonydesouza
Copy link

I am new to iOS development and also to GitHub so apologies if I am doing all this wrong.
Thank you. I found this project very helpful.

iOS6 / Depreciation Warnings
Just wanted to point out a couple of minor changes that I needed for iOS 6 because of depreciation warnings:

Inside method __createWithText in file WToast.m

// UITextAlignmentCenter depreciated
textLabel.textAlignment = NSTextAlignmentCenter;                   

// UILineBreakModeWordWrap depreciated
textLabel.lineBreakMode = NSLineBreakByWordWrapping;    

Tapping a toast performing an action
I also wanted to share a useful addition: performing an action when a toast is tapped

In file WToast.h I declared in the interface block:

     +(void)tappedToast:(UIGestureRecognizer*)recognizer;

And in file WToast.m I implemented:

     +(void)tappedToast:(UIGestureRecognizer*)recognizer
     {
         // Only respond if we're in the ended state (similar to touchupinside)
         if( [recognizer state] == UIGestureRecognizerStateEnded )
         {
             // the label that was tapped
             //UILabel* label = (UILabel*)[recognizer view];

             // DO SOMETHING HERE
         }
     }

Finally I added the following code to your methods __createWithText and __createWithImage to link the tappedToast method to the tap gesture.

     UITapGestureRecognizer* tap = 
              [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(**tappedToast**:)];

     [toast setUserInteractionEnabled:YES];
     [toast addGestureRecognizer:tap];

Hope this is helpful to someone.

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

1 participant