簡體   English   中英

在appDelegate上通過swift接收遠程通知后,關閉視圖並推送(或performSegueWithIdentifier)?

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

在收到遠程通知后,如何在appDelegate文件上向ViewController呈現模態的情況下,將pushViewController推送到dismissViewControllerAnimated函數?

我嘗試了feedVc.navigationController?.pushViewController(vc1,animation:true),但是什么也沒發生。

這是我文件中的一些代碼。

// 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

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)
    })

您在FeedsViewController中創建DealInsideViewController的方式將與模式視圖一起處理。 在我看來,最好的方法是如果您創建DealInsideViewController並在viewDidLoad中從中調用FeedsViewController,那么當您關閉FeedsViewController時,您將返回DealInsideViewController而不是在appDelegate中

嘗試這個:

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: {})

要關閉彈出窗口,只需調用dismissPopoverAnimated ,這將帶您回到FeedsViewController

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM