从右边的SWRevealViewController迅速 [英] SWRevealViewController from the right side on swift
问题描述
我正在使用SWRevealViewController库快速创建一个滑出菜单,但是我正努力将这个菜单放在右侧.我在图书馆的说明中看到了此评论
I am using SWRevealViewController library to make a slide out menu in swift, but I am struggling to put this menu in the right side. I have seen on the library description this comment
// Optional right view controller, can be nil if not used
@property (nonatomic) UIViewController *rightViewController;
但是我对目标C并不熟悉,因此无法迅速做到这一点.这是我的默认(左)菜单代码的一部分:
but I am not familiar with objective C and I am not being able to do this on swift. This is a part of my code for the default(left) menu:
class ViewController: UIViewController, AVAudioPlayerDelegate {
@IBOutlet weak var playlistOutlet: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
playlistOutlet.target = self.revealViewController()
playlistOutlet.action = Selector("revealToggle:")
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
然后从SWRevealViewController库调用exploreViewController
And revealViewController is called from the SWRevealViewController library
推荐答案
我遵循了此解决方案,在前面板视图的控制器中使用以下方法:
I followed this solution, in the controller of the front siding view use this:
override func viewDidLoad() {
super.viewDidLoad()
if self.revealViewController() != nil {
favoritesButton.target = self.revealViewController()
favoritesButton.action = "rightRevealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
别忘了先为项目栏按钮创建出口.在情节提要中,将segue值设置为sw_right
Don't forget to create the Outlet to the item bar button first. In the storyboard, set the segue value to sw_right
首先这对我不起作用,但是干净的帮助.
And first that didn't work for me, but a clean helped.
这篇关于从右边的SWRevealViewController迅速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!