本文介绍了SWRevealViewController推动FrontVC不会引起动画并且不响应通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SWRevealViewController,在这种情况下,我会遇到-

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

演示代码链接- https://www.dropbox.com /s/02fjub838hv95cr/SW​​RevealVC.zip?dl=0

1),我必须在FrontVC中显示ViewController的视图*(在情节提要中的NotificationVC)*.

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

** 2)**此childVC的View有一个按钮*(createNotification)*,该按钮通过 custom segue(SWRevealViewControllerSeguePushController)连接到另一个viewController *(createNotificationVC)*,后者有一个后退按钮

**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)**按下后退按钮的用户会再次返回frontVC,并将某些消息传递给FrontVC.

**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.

在我的frontVC中-

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)

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)


    }

在createNotificationVC的后退按钮动作中,我有-

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

问题-

1)未显示执行自定义搜索时的动画.2)通知消息未传递到frontVC.

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.

这显示了我与front& SWR的SWR连接.后置VC

This shows my SWR connection with front & rear VC

这显示了我的NotificationVC/childVC的连接. * Mark:* ChildVC按钮通过自定义键连接到createNotificationVC.

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

推荐答案

1.SWRevealViewController具有SW_Front& SW_REAR.

1.SWRevealViewController have SW_Front & SW_REAR .

2.要使用此功能,您需要实现此层次结构

2.To use this you need to implement this hierarchy

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

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

3.在您的情况下,该代码为什么不起作用意味着什么.

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

4.在sw_rear中,您必须使用此动画,然后它才能正常工作.

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

这篇关于SWRevealViewController推动FrontVC不会引起动画并且不响应通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 06:05