I am working on a creating a sidebar menu using SWRevealViewController in Swift. Trouble is I get the following error: 'PrincipalViewController' does not have a member named 'revealViewController'
The code I am working on is:
class PrincipalViewController: UIViewController {
@IBOutlet weak var menuButton:UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
// This is the line with the error
if self.revealViewController() != nil {
menuButton.target = self.revealViewController()
menuButton.action = "revealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
// Uncomment to change the width of menu
//self.revealViewController().rearViewRevealWidth = 62
}
}
Any ideas? Thanks a lot
I just found the problem. There is son objective-c code in the app, and the bridging header was not well configured. Thanks a lot
As of Cocoapods >0.36, if you're using Cocoapods to add SWRevealViewController
to your project, don't mess with the bridging header. Just uncomment use_frameworks!
in your Podfile
. Then import SWRevealViewController
into your ViewController.swift
file. Here's a great article that explains it.
To clear this up for others who do not understand the answer's explanation... Make sure the Bridging header file is connected to the Path of the Objective C Bridging Header which is found in the Swift Compiler found in Build Settings of your project...
Here is a link for the way to check if it is there, look under adding it manually for a picture as well...
http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With