0
SWRevealViewControllerを使用してSwift 2.0でサイドメニューを表示しています。GitHubからファイルをダウンロードし、ブリッジヘッダーと接続されたセグを正しく作成しました。私はカスタムボタンを作成していますが、アクション "reveal toggle"は発砲していません。私はどこでミスをしていますか?ジェスチャー認識が正常に発射されないが、SWRevealViewControllerがカスタムナビゲーションバーボタンで機能しないトグル
super.viewDidLoad()
self.navigationController?.navigationBar.topItem?.title = "DASHBOARD"
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
self.navigationController!.navigationBar.titleTextAttributes =
[NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController!.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Teko-Regular", size: 26)!]
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
let btnName = UIButton()
btnName.setImage(UIImage(named: "LeftNavItem"), forState: .Normal)
btnName.frame = CGRectMake(0, 0, 20, 20)
let leftBarButton = UIBarButtonItem()
leftBarButton.customView = btnName
self.navigationItem.leftBarButtonItem = leftBarButton
if self.revealViewController() != nil {
//print(self.revealViewController())
leftBarButton.target = self.revealViewController()
leftBarButton.action = Selector("revealToggle:")
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
「revealToggleを:」間違いは何ですか?
正解です。 「UIBarButton」には「.addTarget」というメンバーはありません。「UIButton」でこれを行い、そのボタンをサブビューとして「UIBarButton」に追加する必要があります。 –
いいえ、UIBarButtonItemと編集されたレスポンスが表示されます。 – mrkbxt