Swift 从警报视图控制器中选择操作,将项添加到段控制器
我已经创建了一个普通段控制器,它有两个类别,分别是类别1和类别2。现在我有了添加按钮,它将我推到新的视图控制器以添加一个项目。单击“完成”按钮添加项目时,我有一个警报控制器,显示我必须保存项目的类别。但我不知道如何在特定的细分市场中获得该项目。如果有人能帮忙的话。 谢谢Swift 从警报视图控制器中选择操作,将项添加到段控制器,swift,ios9,uisegmentedcontrol,uialertcontroller,Swift,Ios9,Uisegmentedcontrol,Uialertcontroller,我已经创建了一个普通段控制器,它有两个类别,分别是类别1和类别2。现在我有了添加按钮,它将我推到新的视图控制器以添加一个项目。单击“完成”按钮添加项目时,我有一个警报控制器,显示我必须保存项目的类别。但我不知道如何在特定的细分市场中获得该项目。如果有人能帮忙的话。 谢谢 使用CommittedItingStyle,您的单元格在滑动时仍将显示“删除”按钮。改为使用editingStyleForRowAtIndexPath:。在中放入if语句以测试选择了哪个段,并相应地返回UITableViewCe
使用CommittedItingStyle,您的单元格在滑动时仍将显示“删除”按钮。改为使用editingStyleForRowAtIndexPath:。在中放入if语句以测试选择了哪个段,并相应地返回UITableViewCellEditingStyle.None(禁用滑动以删除)或.delete(启用滑动以删除)。如果希望能够通过将表格视图置于编辑模式来删除单元格,请同时测试tableView.editing以确定是否使用.delete或.None
@IBAction func done(sender: AnyObject) {
if let item = itemToEdit {
item.text = textField.text!
item.dateTime = dateTime
textField.becomeFirstResponder()
//item.text = textAreaDescription.text!
//textAreaDescription.becomeFirstResponder()
delegate?.itemDetailViewController(self, didFinishEditingItem: item)
} else {
let alertController = UIAlertController(title: "Choose Category", message: "Choose Category To Save Your Item.", preferredStyle: .Alert)
let toDo = UIAlertAction(title: "Category 1", style: .Default) { (action) in
let item = NoToDoItem()
item.text = self.textField.text!
//item.text = textAreaDescription.text!
item.dateTime = self.dateTime
self.delegate?.itemDetailViewController(self, didFinishAddingItem: item)
}
alertController.addAction(toDo)
let notSure = UIAlertAction(title: "Category 2", style: .Default){ (action) in
let notSureItem = NotSureItem()
notSureItem.text = self.textField.text!
//item.text = textAreaDescription.text!
notSureItem.dateTime = self.dateTime
self.delegate?.itemDetailViewController(self, didFinishAddingNotSureItem: notSureItem)
}
alertController.addAction(notSure)
presentViewController(alertController, animated: true, completion: nil)
}
}