Comments (2)
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
from toast.
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!
from toast.
Related Issues (20)
- Crash on iOS 11 when displaying a Toast HOT 2
- Hello, can you add animation styles to toast?
- CSToastPositionBottom display not correct running in iPhone X
- Toast appears behind keyboard, not visible to user HOT 1
- how to bind toast in RoboVM
- The position of activity view is not right HOT 1
- Xcode 10 error HOT 2
- Remove existing Toast HOT 1
- Problem on creating loading view with Toast
- Is there a way to block background view?
- 键盘会挡住 HOT 2
- Could not find module 'Toast_Swift' for target 'armv7-apple-ios'; found: arm64, arm64-apple-ios HOT 1
- Toast not working HOT 1
- makeToast got error HOT 1
- Toast is always showing at bottom
- can you add a setting accessibility?
- feature request: verticalOffset(s)
- Hello
- Is it possible to change the size (width height) of the toast?
- how to change activity color
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toast.