У меня есть MGSwipeTableCell добавляемые в моем Tableview так:detailTextLabel не отображается, но 100% установить
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let reuseIdentifier = "Cell"
var cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as! MGSwipeTableCell!
if cell == nil {
cell = MGSwipeTableCell(style: UITableViewCellStyle.Default, reuseIdentifier: reuseIdentifier)
}
cell.delegate = self
cell.backgroundColor = blue
}
Все работает отлично. Но теперь, если я нажимаю на ячейку, цвет ячейки изменяется, может быть, на секунду на белый, а затем на зеленый (цвет по умолчанию - синий). Это то, что должно произойти, если была нажата клетка:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let mySelectedCell = tableView.cellForRowAtIndexPath(indexPath) as! MGSwipeTableCell!
mySelectedCell.backgroundColor = green
mySelectedCell.detailTextLabel?.text = "Test"
}
Так что цвет должен измениться только на зеленый, не белый, а затем в зеленый и detailTextLabel с текстом «Test» должен отображаться. Надеюсь, вы поможете мне решить эту проблему. Я действительно не знаю, что делать.
Решение:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let reuseIdentifier = "Cell"
var cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as! MGSwipeTableCell!
cell = MGSwipeTableCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: reuseIdentifier)
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.delegate = self
cell.backgroundColor = blue
}
Где и как вы создаете 'объект mySelectedCell', который используется в' Tableview (Tableview: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) '? –
UITableViewCellStyle.Default не имеет субтитров. Вы должны использовать .Value1, .Value2 или .Subtitle в зависимости от того, как вы хотите, чтобы ваша камера выглядела. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/#//apple_ref/c/tdef/UITableViewCellStyle – Tyrelidrel
@alex_p Это была моя ошибка, я должен быть ячейкой вместо mySelectedCell. Я обновил вопрос. – 123