gpt4 book ai didi

ios - Swift UITableView和PickerView/DatePicker

转载 作者:行者123 更新时间:2023-11-28 09:28:30 24 4
gpt4 key购买 nike

我想在点击单元格并用选择器视图数据更改详细标签时,在应用程序的页脚添加选择器视图。我想对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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com