SWRevealViewController pushing FrontVC is not causing animation and not responding to notifications

我是研究僧i 提交于 2019-12-01 12:08:46

问题


I am working on SWRevealViewController in which I have a scenario in which -

Demo code link - https://www.dropbox.com/s/02fjub838hv95cr/SWRevealVC.zip?dl=0

1) I have to present a ViewController's view*(NotificationVC in my storyboard)* in my FrontVC.

**2)**This childVC's View has a button*(createNotification)* which is connected to another viewController*(createNotificationVC)* via custom segue(SWRevealViewControllerSeguePushController),which has a back button

**3)**Pressing the back button user returns to the frontVC again with some message to be passed to the FrontVC.

For this message passing,I am using notification Pattern.

In my frontVC -

override func viewDidLoad()
    {
        super.viewDidLoad()

        self.revealViewController().delegate = self

        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

        if self.revealViewController() != nil
        {

            self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
            self.view.addGestureRecognizer(self.revealViewController().tapGestureRecognizer())
        }

        let NtfctnVC = self.storyboard?.instantiateViewControllerWithIdentifier("NtfctnVC")

        addChildViewController(NtfctnVC!)
        NtfctnVC!.view.frame = CGRectMake(0, 0,self.customView.frame.width, self.customView.frame.height)
        customView.addSubview(NtfctnVC!.view)//add the childVC's view

NtfctnVC!.didMoveToParentViewController(self)

        NSNotificationCenter.defaultCenter().addObserver(self, selector: "methodOfReceivedNotification:", name:"NotificationIdentifier", object: nil)
    }
    func methodOfReceivedNotification(notification: NSNotification)
    {
        //Take Action on Notification
        let userInfo = notification.userInfo
        print(userInfo!["sentTag"] as? Int)
        NSNotificationCenter.defaultCenter().removeObserver(self)


    }

In the createNotificationVC's back button action,I have -

 @IBAction func bck(sender: AnyObject)
    {
        let frontVC = self.storyboard?.instantiateViewControllerWithIdentifier("frontNVC") //frontNVC is the navigation controller of frontVC

        NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: nil, userInfo: ["sentTag":2])
        self.revealViewController().pushFrontViewController(frontVC, animated: true)//here the frontVC is presented with no animation.
}

Problem -

1)The animation while performing custom segue is not been shown. 2)Notifications message are not being passed to the frontVC.

Please help me regarding this as I have tried lot many stuff & googling, but in vain. Thanks.

This shows my SWR connection with front & rear VC

This shows my NotificationVC/childVC's connection. *Mark:*ChildVC button connected via custom segue to createNotificationVC.


回答1:


1.SWRevealViewController have SW_Front & SW_REAR .

2.To use this you need to implement this hierarchy

->swrevealviewcontroller -->swfront--->viewcontroller
-->swrear---->viewcontroller

3.in your case why that code doesn't work means .

4.From sw_rear you have to use this animation ,then it will work sure.



来源:https://stackoverflow.com/questions/35699581/swrevealviewcontroller-pushing-frontvc-is-not-causing-animation-and-not-respondi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!