我正在使用swift4,我有两种语言的应用程序:阿拉伯语和英语,我想将SWRevealViewController
应用于这两种语言
如在图像中我执行两个segue sw_rear
和sw_right
这就是我在每个有侧边菜单的页面中所做的,我在viewDidLoad中调用了这个函数:
func setSideMenu() {
if( revealViewController() != nil) {
if(CurrentLanguage.currentAppleLanguage() == "en") {
revealViewController().rearViewRevealWidth = 100
revealViewController().rightViewRevealWidth = 0
menuButton.addTarget(self.revealViewController(), action: #selector(SWRevealViewController.revealToggle(_:)), for: .touchUpInside)
revealViewController().rightRevealToggle(animated: false)
view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
} else {
revealViewController().rightViewRevealWidth = 100
revealViewController().rearViewRevealWidth = 0
menuButton.addTarget(self.revealViewController(), action: #selector(SWRevealViewController.rightRevealToggle(_:)), for: .touchUpInside)
view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
}
menuButton是Outlet到菜单按钮
@IBOutlet var menuButton: UIButton!
当我点击菜单按钮时它可以正常工作,但是如果我从左边交换屏幕时CurrentLanguage.currentAppleLanguage() == "en"
打开侧面菜单,如果我从右边交换它,它会打开然后因revealViewController().rightViewRevealWidth = 0
而关闭,我想在阿拉伯语案例中从右边打开菜单,在英语情况下从左侧打开菜单,并且无法从另一侧交换,我该怎么办?