Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何滑出侧菜单栏?迅速地_Ios_Swift_Xcode_Swift3 - Fatal编程技术网

Ios 如何滑出侧菜单栏?迅速地

Ios 如何滑出侧菜单栏?迅速地,ios,swift,xcode,swift3,Ios,Swift,Xcode,Swift3,当我向左滑动时,如何滑出侧菜单栏?当我单击collectionView时,它将如何自动滑出?我使用的是tableView和约束,我对该约束的出口是rightMargin import UIKit import ViewPagerController class OptionTableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var righ

当我向左滑动时,如何滑出侧菜单栏?当我单击collectionView时,它将如何自动滑出?我使用的是tableView和约束,我对该约束的出口是rightMargin

import UIKit
import ViewPagerController

class OptionTableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var rightMargin: NSLayoutConstraint!
    @IBOutlet weak var optionTableView: UITableView!

let option = ["LOG IN","SIGN UP","EDIT PROFILE", "LOG OUT"]
let storyBoardId = ["LogInViewController","SignUpViewController","UserEditPageViewController", "None"]

override func viewDidLoad() {
    super.viewDidLoad()

  var appearance = ViewPagerControllerAppearance()
  appearance.tabMenuAppearance.backgroundColor = UIColor.black

    let screenWidth = UIScreen.main.bounds.width
    rightMargin.constant = screenWidth
}
 override func viewDidAppear(_ animated: Bool) {

    super.viewDidAppear(animated)
    self.rightMargin.constant = 100

    UIView.animate(withDuration: 0.3 , animations: {
           self.view.layoutIfNeeded()
   })
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return option.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

      let cell = optionTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    cell.textLabel?.text = option[indexPath.row]
    cell.textLabel?.font = UIFont(name: "Arial", size: 10)
        return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if let logInViewController = storyboard?.instantiateViewController(withIdentifier: storyBoardId[indexPath.row]) {
        navigationController?.pushViewController(logInViewController, animated: true)
    }
}
}

这些功能可以让您通过滑动打开自己的选项

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return true
}

override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
let more = UITableViewRowAction(style: .normal, title: "More") { action, index in
    print("more button tapped")
}
more.backgroundColor = .lightGray

let favorite = UITableViewRowAction(style: .normal, title: "Favorite") { action, index in
    print("favorite button tapped")
}
favorite.backgroundColor = .orange

let share = UITableViewRowAction(style: .normal, title: "Share") { action, index in
    print("share button tapped")
}
share.backgroundColor = .blue

return [share, favorite, more]
 }

这些可以让你通过滑动打开自己的选择

override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return true
}

override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
let more = UITableViewRowAction(style: .normal, title: "More") { action, index in
    print("more button tapped")
}
more.backgroundColor = .lightGray

let favorite = UITableViewRowAction(style: .normal, title: "Favorite") { action, index in
    print("favorite button tapped")
}
favorite.backgroundColor = .orange

let share = UITableViewRowAction(style: .normal, title: "Share") { action, index in
    print("share button tapped")
}
share.backgroundColor = .blue

return [share, favorite, more]
 }

我也在找这个…我也在找这个。。。