从 didReceiveLocalNotification 加载新视图
我已经寻找解决方案几个小时了,我的问题非常简单。 我有一个触发的本地通知,我想加载一个新视图,以便在触发通知并且用户单击“查看”按钮时向用户显示。 这可能吗?如果可以,我该怎么做?
提前致谢 :)
Ive been searching for a solution for hours and my question is really simple.
I have a local notification that fires and i want to load a new view to show the user when the notification has been fired and the user have clicked the "view" button.
Is this possible and if so, how do i do it?
Thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 appDelegate 中放置以下代码:
当您的应用程序收到本地通知时调用此方法,您还可以在创建通知时使用“notif”对象来存储有用的数据。
如果您有一个视图 MyView 并且它是 xib 文件(例如 MyView.xib,您将主视图设置为 MyView 类),您可以执行类似的操作来加载它
在 MyView.m 添加一个类方法以从 xib 创建新视图:
然后在本地通知回调中,您可以使用以下内容:
其中 window 是您通常在应用程序委托模板中拥有的属性。
In your appDelegate put this code:
this method is called when your app receive the local notification and you can also use the "notif" object to store useful data when you create the notification.
If you have a view MyView and it's xib file (like MyView.xib where you set the main view as MyView class) you can do something like this to load it
In MyView.m add a class method to create a new view from a xib:
then in the local notification callback you can have something like:
Where window is the property you normally have in the app delegate template.