0

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.

enter image description here

This shows my SWR connection with front & rear VC

enter image description here

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

G.Abhisek
  • 1,034
  • 11
  • 44
  • can you explain it clearly little bit? – Kishore Kumar Feb 29 '16 at 12:53
  • @KishoreKumar Bro exactly, if you can please download the source code and run it once, you will get to know what I am saying. Can you please see the source code once? I have shared a link. – G.Abhisek Feb 29 '16 at 12:55
  • ok wait a minute i will check it @G.Abhisek – Kishore Kumar Feb 29 '16 at 12:58
  • @KishoreKumar Thanks a lot bro. – G.Abhisek Feb 29 '16 at 13:00
  • bro i can run that code your pods_swrevealVC.framework is missing.can you tell me what you want exactly :) @G.Abhisek – Kishore Kumar Feb 29 '16 at 13:03
  • @KishoreKumar Bro the animations are not working when I move from the child vc's view to the createNotificationVC & please check the createNotificationVC's back button, If i want to pass some messages via notification. that's too is not working. – G.Abhisek Feb 29 '16 at 13:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/104871/discussion-between-kishore-kumar-and-g-abhisek). – Kishore Kumar Feb 29 '16 at 13:24

1 Answers1

0

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.

enter image description here

Kishore Kumar
  • 4,265
  • 3
  • 26
  • 47
  • As you can see ChildVC's button connected via custom segue to createNotificationVC. And NotificationVC/childVC whose view I have added in the frontVC is also added to the sw_front VC stack , so why is it so? – G.Abhisek Feb 29 '16 at 13:37
  • Ya bro I had a look.. I have a requirement like that itself. I am connecting like that because I want my createNotificationVC to act as a frontVC when user swipes & it should show the slide menu. – G.Abhisek Feb 29 '16 at 13:48
  • Please give suggestions bro – G.Abhisek Feb 29 '16 at 13:49
  • 1
    ok add one new swrevealviewcontroller ,then add front as your createnotification view ,sw_rear to your notification screen now use that animation try this. – Kishore Kumar Feb 29 '16 at 13:51
  • But while moving to the old frontVC it would result in error!! – G.Abhisek Feb 29 '16 at 14:15
  • @G.Abhisek super happy coding :) – Kishore Kumar Mar 01 '16 at 05:00
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/104950/discussion-between-g-abhisek-and-kishore-kumar). – G.Abhisek Mar 01 '16 at 05:00