警报框按钮重定向
我想知道我们是否真的可以将警报框重定向到特定视图。这意味着,当他们单击通知警报上的“查看”时,它会将他们重定向到特定视图,就像弹出的短信通知一样。有关于这是如何工作的任何想法吗?
I would like to know if we can actually redirect the alert box to a specific view. Meaning that when they clicked on "View" which is on the notification alert, it will redirect them to a particular view, just like the text message notification pop up. Is there any idea on how this works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的问题来看,您可能意味着两种类型的警报对话框:
UIAlertView
我将按顺序处理它们。
首先,如何处理 UIAlertView“查看”按钮的点击。
实现
alertView:didDismissWithButtonIndex:
控制器类中UIAlertViewDelegate
协议的方法,以及当您init
UIAlertView
将其delegate
设置为self
。然后,当用户单击标记为“View”的按钮时,执行以下操作:其次,如何处理触发应用程序启动的
UILocalNotification
。关于
UILocalNotification
状态:
您需要在应用程序委托类的
application:didFinishLaunchingWithOptions:
方法中编写用于处理此启动情况的代码。如果您在应用程序运行时碰巧收到
UILocalNotification
,Apple 文档指出:编辑:要立即将用户带到特定视图,您可以手动将某些内容推送到
UINavigationController
堆栈(如果您的应用程序通常使用导航控制器运行,则这样做是有意义的),或 呈现一个模态视图控制器。我在那里链接了两者的指南。From your question, you could mean two types of alert dialogs:
UIAlertView
UILocalNotification
alert dialog, shown when the application is in the background ("just like the text message notification pop up")I will address them in order.
First, how to handle a
UIAlertView
"View" button click.Implement the
alertView:didDismissWithButtonIndex:
method of theUIAlertViewDelegate
protocol in your controller class, and when youinit
theUIAlertView
set itsdelegate
toself
. Then when the user clicks a button marked e.g. "View", do this:Secondly, how to handle a
UILocalNotification
which triggers an application launch.Apple docs on
UILocalNotification
state:You need to write code for handling this launch case in your app delegate class, in the
application:didFinishLaunchingWithOptions:
method.IF you happen to get a
UILocalNotification
while the app is running, Apple docs state:EDIT: To take the user to a specific view straight away, you can manually push something onto a
UINavigationController
stack (if your app usually operates with navigation controllers, it makes sense to do this), or present a modal view controller. I've linked there to guides for both.