2016-03-08 2 views
0

Прежде всего, я Распад TableView и все нормально, но когда я кнопку перетащить, что заставит меня перейти к другому контроллеру он дает мне ошибкунеожиданно обнаружил ноль tableView.registerNib

Примечание что кнопка внутри tableviewcell

fatal error: unexpectedly found nil while unwrapping an Optional value

это мой код

// Do any additional setup after loading the view, typically from a nib. 
    tableData = [ 
     ["title": "Gender", "height": "118", "cellID": "cell1"], 
     ["title": "Componnet", "height": "205", "cellID": "cell2"], 
     ["title": "Lille Attribute", "height": "905", "cellID": "cell3"], 
     ["title": "Sensory Effect", "height": "215", "cellID": "cell4"], 
     ["title": "Emotional Messages", "height": "338", "cellID": "cell5"], 
     ["title": "Personalities", "height": "336", "cellID": "cell6"], 
     ["title": "Country", "height": "97", "cellID": "cell7"], 
     ["title": "Season", "height": "94", "cellID": "cell8"] 
    ] 
    expandSections = NSMutableArray() as [AnyObject] 
    for var i = 0; i < tableData.count; ++i { 
     expandSections .append(false); 
    } 
    tableView.registerNib(UINib(nibName: "TableViewCell1", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell1") // in this line 
    tableView.registerNib(UINib(nibName: "TableViewCell2", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell2") 
    tableView.registerNib(UINib(nibName: "TableViewCell3", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell3") 
    tableView.registerNib(UINib(nibName: "TableViewCell4", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell4") 
    tableView.registerNib(UINib(nibName: "TableViewCell5", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell5") 
    tableView.registerNib(UINib(nibName: "TableViewCell6", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell6") 
    tableView.registerNib(UINib(nibName: "TableViewCell7", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell7") 
    tableView.registerNib(UINib(nibName: "TableViewCell8", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "cell8") 
+1

Как вы создали табличное представление, можете ли вы показать один раз –

+0

Вы зарегистрировали свой nib? – iamalizade

+0

Я создаю его программно –

ответ

0

Похоже, ваш Tableview в настоящее время объявлен как UITableView! и он не инициализируется, когда код, который вы выложили выше, выполняется. Убедитесь, что tableView не ноль, когда вы регистрируете наконечники. Добавление всего кода очень помогло бы.

Смежные вопросы