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 Doesn't Appear Inside CollectionView didSelectItemAtIndexPath #27

Closed
mikewalkerjr opened this issue May 4, 2015 · 7 comments · Fixed by #28
Closed

Toast Doesn't Appear Inside CollectionView didSelectItemAtIndexPath #27

mikewalkerjr opened this issue May 4, 2015 · 7 comments · Fixed by #28

Comments

@mikewalkerjr
Copy link

I have a UICollectionView where I let the user select up to 5 photos. After 5 are selected I'm trying to show a toast message informing the user only 5 photos can be selected. I am using JLToast throughout the code, however here it does not show. The UICollectionView is within a UIViewController. Here is the code I am using within didSelectItemAtIndexPath:

        println("show toast")
        JLToast.makeText(NSLocalizedString("select_up_to_five_photos", comment: "Select up to 5 photos")).show()            

The println gets printed correctly, but I don't see a toast.

@devxoul
Copy link
Owner

devxoul commented May 4, 2015

Your code doesn't seem to have any problem. Could you please let me know more context? I can't figure out the problem with your code.
Thanks!

@mikewalkerjr
Copy link
Author

I actually was playing with the code some and it actually has to do with how the ViewController is presented. Originally I had used navigationController.presentViewController, and using that I was not able to see a Toast message.

If I changed the code to use navigationController.pushViewController, then the toast works properly.

@devxoul
Copy link
Owner

devxoul commented May 4, 2015

You mean the toast message from modal view controller won't be shown?

@mikewalkerjr
Copy link
Author

Yes that's correct

@devxoul
Copy link
Owner

devxoul commented May 5, 2015

Could you please test with this?

Replace the line 104 at JLToast.swift:

Before

UIApplication.sharedApplication().keyWindow?.subviews.first?.addSubview(self.view)

After

UIApplication.sharedApplication().windows.first?.addSubview(self.view)

If it works, I'll make a new release.

@mikewalkerjr
Copy link
Author

Yes that fixed it.

@devxoul
Copy link
Owner

devxoul commented May 5, 2015

Great. Then I'll make a new release. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants