【发布时间】:2017-07-19 17:15:28
【问题描述】:
我想编辑从日历中提取的一个事件。我的问题是我可以看到事件详细信息,但没有显示编辑按钮,因此用户无法对其进行编辑。
这是代码的相关部分
class ViewController: UIViewController, UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, UIPickerViewDelegate, UIPickerViewDataSource, EKEventEditViewDelegate {
let eventStore = EKEventStore()
var hibakURL = [String]()
var hibasEventek = [EKEvent]()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "segue" {
// Configure the destination event view controller
let eventViewController = segue.destination as! EKEventViewController
// Fetch the index path associated with the selected event
let indexPath = self.hibaTableView.indexPathForSelectedRow!
// Set the view controller to display the selected event
eventViewController.event = self.hibasEventek[indexPath.row]
print(indexPath.row)
// Allow event editing
eventViewController.allowsEditing = true
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
let numofRows = hibakURL.count
return numofRows
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = hibaTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = hibasEventek[indexPath.row].title
cell.textLabel?.font = UIFont(name: (cell.textLabel?.font.fontName)!, size:14)
return cell
}
}
我希望这就够了!
抱歉,如果帖子中的某些内容不正确,但这是我在 SO 上的第一篇帖子。
【问题讨论】: