简体   繁体   English

在appDelegate上通过swift接收远程通知后,关闭视图并推送(或performSegueWithIdentifier)?

[英]DismissView and push (or performSegueWithIdentifier) after Receive Remote Notification on appDelegate by swift?

How can i pushViewController after the modal which was presented ViewController on appDelegate file did dismissViewControllerAnimated function after receive remote notification? 在收到远程通知后,如何在appDelegate文件上向ViewController呈现模态的情况下,将pushViewController推送到dismissViewControllerAnimated函数?

I tried feedVc.navigationController?.pushViewController(vc1, animated: true) but nothing happended. 我尝试了feedVc.navigationController?.pushViewController(vc1,animation:true),但是什么也没发生。

This is some code from my files. 这是我文件中的一些代码。

// AppDelegate.swift // AppDelegate.swift

self.window?.rootViewController = storyboard.instantiateViewControllerWithIdentifier("tabberController") as! DefaultTabbarController // this is FeedsViewController

let navigationController = storyboard.instantiateViewControllerWithIdentifier("beatingDealView") as! UINavigationController

let bealBiddingVc: BeatBiddingModalViewController = navigationController.topViewController as! BeatBiddingModalViewController

bealBiddingVc.dealId = tempDealId
bealBiddingVc.beatBiddingText = tempDealText
bealBiddingVc.dealName = tempDealName

self.window?.rootViewController?.presentViewController(navigationController, animated: true, completion: {})

// BeatBiddingModalViewController.swift // BeatBiddingModalViewController.swift

self.dismissViewControllerAnimated(true, completion: {

        let vc1: DealInsideViewController = self.storyboard?.instantiateViewControllerWithIdentifier("pushDealInsideFirstView") as! DealInsideViewController
        let feedVc:FeedsViewController = self.storyboard?.instantiateViewControllerWithIdentifier("feedsDisplayView") as! FeedsViewController

        feedVc.feedsTableClickCheck = false
        feedVc.dealIdFromNoti = self.dealId
        feedVc.navigationController?.pushViewController(vc1, animated: true)
    })

The way you are doing the DealInsideViewController that you are creating in FeedsViewController will be disposed with the modal view. 您在FeedsViewController中创建DealInsideViewController的方式将与模式视图一起处理。 The best way in my view if for you to create DealInsideViewController and call the FeedsViewController from it in viewDidLoad so when you dismiss FeedsViewController you will be back in DealInsideViewController not in the appDelegate 在我看来,最好的方法是如果您创建DealInsideViewController并在viewDidLoad中从中调用FeedsViewController,那么当您关闭FeedsViewController时,您将返回DealInsideViewController而不是在appDelegate中

Try This: 尝试这个:

self.window?.rootViewController = storyboard.instantiateViewControllerWithIdentifier("tabberController") as! FeedsViewController

let navigationController = storyboard.instantiateViewControllerWithIdentifier("beatingDealView") as! UINavigationController

let bealBiddingVc: BeatBiddingModalViewController = navigationController.topViewController as! BeatBiddingModalViewController

bealBiddingVc.dealId = tempDealId
bealBiddingVc.beatBiddingText = tempDealText
bealBiddingVc.dealName = tempDealName

self.window?.rootViewController?.presentViewController(navigationController, animated: true, completion: {})

To dismiss the popover just call dismissPopoverAnimated and that will take you back to FeedsViewController 要关闭弹出窗口,只需调用dismissPopoverAnimated ,这将带您回到FeedsViewController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM