我正在开发 SWRevealViewController,其中我有一个场景 -
演示代码链接 -https://www.dropbox.com/s/02fjub838hv95cr/SWRevealVC.zip?dl=0 https://www.dropbox.com/s/02fjub838hv95cr/SWRevealVC.zip?dl=0
1)我必须在 FrontVC 中呈现 ViewController 的视图*(故事板中的 NotificationVC)*。
**2)**这个childVC的View有一个按钮*(createNotification)*,它通过连接到另一个viewController*(createNotificationVC)*自定义转场(SWRevealViewControllerSeguePushController),有一个后退按钮
**3)**按下后退按钮,用户再次返回到 frontVC,并将一些消息传递到 FrontVC。
对于此消息传递,我使用通知模式。
在我面前VC——
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
Ntfc tnVC!.didMove ParentViewController(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 的后退按钮操作中,我有 -
@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)执行自定义segue时的动画未显示。
2)通知消息没有被传递到frontVC。
请帮助我解决这个问题,因为我尝试了很多东西并谷歌搜索,但徒劳无功。谢谢。
这显示了我的 SWR 与前后 VC 的连接
这显示了我的NotificationS/child的连接。 *标记:*ChildVC 按钮通过自定义 segue 连接以创建通知 VC。