ios - Swift UITableView和PickerView/DatePicker

标签 ios uitableview swift datepicker xcode6

我想在点击单元格并用选择器视图数据更改详细标签时,在应用程序的页脚添加选择器视图。我想对DatePicker做同样的思考,但只在一个单元格中(名为Service appt的单元格)。日期)。我学了一些教程,但没找到任何有用的东西。
这是我的代码:

import UIKit

class Service2Appointment: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var TableView: UITableView!

@IBOutlet weak var pickerView: UIPickerView!

let FormName = ["State","City","Vehicle Reg Number","Location","Current Kms","Service appt. Date","Service appt. Type","Pick-up Vehicle","Discount Code","Service Notes"]

let textCellIdentifier = "TextCell"

override func viewDidLoad() {
    super.viewDidLoad()
    pickerView.hidden = true
    TableView.delegate = self
    TableView.dataSource = self
    self.TableView.rowHeight = 70
    TableView.backgroundView = UIImageView(image: UIImage(named: "background.png"))
    self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK:  UITextFieldDelegate Methods
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }


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

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
   var cell = TableView.dequeueReusableCellWithIdentifier(FormName[indexPath.row], forIndexPath: indexPath) as! UITableViewCell

    if (indexPath.row % 2 == 0) {
        cell.backgroundColor = UIColor.clearColor()
    }else{

        cell.backgroundColor = UIColor.clearColor()
        cell.textLabel?.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.0)
    }

    let row = indexPath.row

    cell.detailTextLabel?.text = FormName[row]

    cell.textLabel?.text = FormName[row]
    cell.textLabel?.textColor = UIColor.whiteColor()
    return cell
}
// MARK:  UITableViewDelegate Methods
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        TableView.deselectRowAtIndexPath(indexPath, animated: true)

        let row = indexPath.row
        println(FormName[row])
    }
}

提前非常感谢。

最佳答案

关于ios - Swift UITableView和PickerView/DatePicker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30382325/

相关文章:

ios - 今天,扩展 View 在 View 出现后会重新调整自身。 iOS swift

ios - 如何获得准确的电池电量?

ios - TableViewCell 不要重用

ios - 错误 : 'NSInvalidArgumentException' . .. 无法识别的选择器发送到实例

iOS Swift UIWebView 链接坐标

ios - 如何让 XLPagerTabStrip 将选定的选项卡居中?

ios - 如何让 setInitialRoute 在不同的 View 上启动我的 Flutter iOS 应用程序?

ios - 显示在 MBProgressHUD 顶部的 UITableView 标题

ios - dateFromString 给出 nil,swift

ios - 获取 func imagePickerController(picker : UIImagePickerController, didFinishPackingWithMediaInfo: [String : AnyObject]) 的返回值