Это мое приложение:Редактирование ячейки точек при редактировании TableView
Когда я нажмите кнопку Edit ('' Редигер ''), я получаю следующее:
Итак, мой вопрос: как сделать круглый красный круг и индикатор раскрытия скрытым во время редактирования таблицы? Как круг, так и индикатор раскрытия являются imageViews.
Вот код для пользовательской ячейки (я вырезан ненужные части):
class KundeavisCell: UITableViewCell {
@IBOutlet weak var unreadImage: UIImageView!
@IBOutlet weak var disclosureIndicatorImage: UIImageView!
}
И контроллер с таблицей вида:
class KundeaviserVC: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var redigerOutlet: UIBarButtonItem!
var stores = ["Rema 1000", "Coop Obs", "Coop Extra"]
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "KundeavisCell", for: indexPath) as! KundeavisCell
// Here i edit the cell
return cell
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return stores.count
}
@IBAction func tableViewEditingPressed(_ sender: Any) {
if tableView.isEditing {
tableView.setEditing(false, animated: true);
redigerOutlet.style = UIBarButtonItemStyle.plain;
redigerOutlet.title = "Rediger";
} else {
tableView.setEditing(true, animated: true);
redigerOutlet.title = "Ferdig";
redigerOutlet.style = UIBarButtonItemStyle.done;
}
}
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
let itemToMove = stores[sourceIndexPath.row]
stores.remove(at: sourceIndexPath.row)
stores.insert(itemToMove, at: destinationIndexPath.row)
}
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
return UITableViewCellEditingStyle.none
}
func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
return false
}
}
Я знаю, что я могу отступ изображения влево, устанавливая ограничения на них, но я хочу полностью скрыть их. Я нашел вопрос об этом: Link, но, к сожалению, он был написан 5 лет назад и в Objective-C.
Любая помощь будет очень признательна, спасибо!
К сожалению, я не кодирую в Swift. Однако попробуйте подкласс UITableViewCell и переопределите ** setEditing: animated: **, как указано в этом разделе: http://stackoverflow.com/questions/19678695/customising-cell-editing-style-in-uitableview-in-ios, оттуда вы можете настроить свои ImageViews на скрытые = YES/NO в зависимости от того, как вы редактируете/останавливаете редактирование. –