从后台进入 iPhone 应用程序的主屏幕
我试图找出用户从后台返回后如何将其带到我的应用程序的主屏幕。
当用户来自后台时,我不想一直将用户带到主屏幕。
但只有当他点击我的推送通知警报上的“查看”并且应用程序当时在后台时,我才想把他带到主屏幕。
但是,如果他一般从后台打开应用程序,他应该转到上次单击主页按钮并转到后台时离开的地方,
如有任何帮助,我们将不胜感激。
谢谢, 约格什
I am trying to find out how should i take the user to the home screen of my app, after he comes back from the background.
I don't want to take the user to the home screen all the time when he is coming from the background.
But only when he clicks "view" on my push notification alert and the app was in the background at that time, i want to take him to the home screen.
But if he is opening the app from the background in general he should go where ever he was left off last time he clicked on the home button and went to background
Any help is appreciated.
Thanks,
Yogesh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
info.plist 中有一个 bool 属性——应用程序不在后台运行,
您应该根据您的要求更改它。
There one bool property in info.plist--Application does not run in background
you should change that according to your requirement.
好吧,我不确定这种做法是否正确,但这就是我所做的,因为我的应用程序有一个 tabbarcontroller,我做的第一件事是我实现了 tabbarcontroller“didSelectViewController”的委托方法
// 通过这样做每次你选择一个选项卡时,它都会返回到该选项卡的 rootViewController
,然后在 didReceiveRemoteNotification 上
,让我解释一下它在做什么,它会检查当前选项卡是否为 1,如果是,那么它将删除其中的所有视图导航堆栈将视图带到根视图,如果当前选项卡不是 1,则将其设置为 1。
Ok i am not sure if this right way of doing it or not, but this is what i did, as my application have a tabbarcontroller the first thing that i did is i implemented the delegate method of the tabbarcontroller "didSelectViewController"
// By doing this every time you select a tab it will come back to the rootViewController of that tab
and then on didReceiveRemoteNotification
so let me explain what this is doing, it is checking if the current tab is 1 if it is then it will remove all the view from the navigation stack to bring the view to the root view, if the current tab is not 1 and just make it to 1.