0

I have a NavigationView I want to drag to display the TableCell through the right drag to hide left. I made a mistake in the UISwipeGestureRecognizer action event. I do not know how to handle how someone can give me suggestions Here is my code

import UIKit

class NavigationViewController: UIViewController {
    var menu_vc: MenuViewController!
    @IBOutlet weak var navigation_item: UINavigationItem!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.navigationBar.barTintColor = UIColor.blueColor()
        menu_vc = self.storyboard?.instantiateViewControllerWithIdentifier("MenuViewController") as! MenuViewController
        let swipeRight = UISwipeGestureRecognizer(target: self, action: "clickRight")
        swipeRight.direction = UISwipeGestureRecognizerDirection.Right
        self.view.addGestureRecognizer(swipeRight)

        let swipeLeft = UISwipeGestureRecognizer(target: self, action: "clickRight")
        swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
        self.view.addGestureRecognizer(swipeLeft)

    }

    func clickRight(gesture : UISwipeGestureRecognizer)-> Void 
    {
    switch gesture.direction
        {
    case UISwipeGestureRecognizerDirection.Right:
        show_menu()
    case UISwipeGestureRecognizerDirection.Left:
        close_on_swipe()
    default:
        break
        }
    }

    func close_on_swipe()
    {
    if AppDelegate.menu_bool
    {
    }else
    {
   close_menu()
    }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    @IBAction func btn_show_navigation(sender: UIButton) {
        if AppDelegate.menu_bool
        {
        show_menu()
        }else
        {
        close_menu()
        }

    }

    @IBAction func btn_search(sender: UIButton) {
        NSLog("bbb", "ccc")
    }
    func show_menu()
    {
        UIView.animateWithDuration(0.3){ ()->Void in
            self.menu_vc.view.frame = CGRect(x: 0,y: 0,width: 
UIScreen.mainScreen().bounds.size.width,height: 
UIScreen.mainScreen().bounds.size.height)
            self.addChildViewController(self.menu_vc)
            self.view.addSubview(self.menu_vc.view)
            AppDelegate.menu_bool = false
            }
    }
    func close_menu()
    {
        UIView.animateWithDuration(0.3, animations: { ()->Void in
            self.menu_vc.view.frame = CGRect(x: -UIScreen.mainScreen().bounds.size.width,y: 0,width: UIScreen.mainScreen().bounds.size.width,height: UIScreen.mainScreen().bounds.size.height)}){(finished) in
                self.menu_vc.view.removeFromSuperview()

        }
        AppDelegate.menu_bool = true

    }
}

After pulling I get the following error

/* 2018-07-13 13:21:22.610 AppPasscon[10650:324600] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppPasscon.NavigationViewController clickRight]: unrecognized selector sent to instance 0x14eed9230' */

CodeChimp
  • 4,745
  • 6
  • 45
  • 61
  • What version of Swift are you using exactly? If it's 3+, you should use `#selector()`. For the rest, the signature of "clickRight" is not correct. When you wrote `"clickRight"`, you are saying there is no parameter to that method, but there is. – Larme Jul 13 '18 at 07:35
  • #selector() not woking swift 3 :( – Nguyễn Quang Thủ Jul 13 '18 at 08:42
  • https://stackoverflow.com/questions/39205613/selector-syntax-for-swift-3-0 – Larme Jul 13 '18 at 08:43

0 Answers0