-
Notifications
You must be signed in to change notification settings - Fork 714
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
Show without view controller? #1
Comments
Hey Tyler, I think you're confusing controllers and views. Toast can care less about controllers, all it needs is a view to be presented in. If self is a UIViewController, and you use [self makeToast:@"Hello World"], you're going to get an error. You need to use [self.view makeToast:@"Hello World"], which references the view property assigned to that controller, not the controller itself. There's a few ways to do what you want. If you're using a UINavigationController, you can just display the toast in the navigation controller's container view. Then it doesn't matter if view controllers are being pushed/popped from the stack. You can do that like this: [self.navigationController.view makeToast:@"Hello World"]; Another thing you can do is add the toast directly to the window (since UIWindow inherits from UIView). This is useful if you're not using a navigation controller: [self.view.window makeToast:@"Hello World"]; Generally, it's bad practice to add something directly to the UIWindow unless you really need to so if you're using a navigation controller, use the first method. Hope that helps. Charles |
Thanks Charles! You're right, I did mean the view controller's view, not the view controller itself. I didn't think of using the navigation controller, good one! |
Love it! Easy, works great, thanks!
One great thing about Toasts on Android is that they show even if your activity is finished. Can you think of a way to do that with your iPhone Toast code? If I use [self makeToast], where self is a UIViewController, the toast won't show if I immediately pop the view controller. Any ideas?
The text was updated successfully, but these errors were encountered: