вот код: произошлоКак использовать идентификатор ячейки в виде таблицы?
import UIKit
class SliderMenuTableViewController: UITableViewController {
var tableArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
let age: String
age = String(LoginViewController.AGE)
let Profile = LoginViewController.NAME! + ", " + age
tableArray = [Profile,"Second","Third","Fourth","Logout"]
}
// table view delegate method
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier(tableArray[indexPath.row], forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = tableArray[indexPath.row]
if cell.textLabel?.text == tableArray[0] {
cell.imageView?.frame = CGRectMake(10, 10, 50, 50)
cell.imageView!.layer.borderWidth = 1
cell.imageView!.layer.masksToBounds = false
cell.imageView!.layer.borderColor = UIColor.blackColor().CGColor
cell.imageView!.layer.cornerRadius = cell.imageView!.frame.width/2
cell.imageView!.clipsToBounds = true
cell.imageView?.image = LoginViewController.AVATAR
}
return cell
}
Ошибка:
Нагрузочный приложение из-за неперехваченного исключением 'NSInternalInconsistencyException', причина: «не удалось из очереди ячейки с идентификатором Viktor, факультативный (29) - необходимо зарегистрироваться перо или класс для идентификатора или подключение ячейки прототипа в раскадровке
Я понимаю, что я должен идентификатор ячейки, как это сделать из кода вызвать в «профиль» переменного, что в моем tableArray
является не статичным, и я не могу идентифицировать его из раскадровки?
В интерфейсе Builder перетащите ячейку таблицы в виде таблицы. Затем вы можете добавить идентификатор. – vadian