uitableview - Swift: Can't access IBOutlet in custom UITableViewCell -


I create a custom UITableViewCell subclass with a @IBOutlet property 'Label' is, but this is not equal to when I do viewDidLoad .

TableViewController.swift

  TableViewController use it to import UIKit class: UITableViewController {viewDidLoad () {super.viewDidLoad () var cell = TableViewCell function overrides (style: UITableViewCellStyle.Default, reuseIdentifier: zero) println (cell.label) // null}}  

Tabilwusiel. Skift

Import UIKit Classes Table Selection Seal: UITABLE VISUAL {@IBOOTLET WEIGHT Labels: UILABLE! }

Main.storyboard

  & lt; tableViewCell contentMode = "scaleToFill" selectionStyle = "default" indentationWidth = "10" reuseIdentifier = "TableViewCell" id = "CNV-ZQ-OVR" customClass = "TableViewCell" customModule = "SimpleTable" customModuleProvider = "target" & gt; & Lt; Autoresizing mask key = "autoresizingmask" /> & Lt; tableViewCellContentView key = "contentView" opaque = "no" ClipsSubviews = "yes" MultipleTouchEnabled = "yes" ContentMode = "center" tableViewCell = "CNV-ZQ-OVR" id = "3Qh-AQ-Ys2" & gt; & Lt; Autoresizing mask key = "autoresizingmask" /> & Lt; Subviews & gt; & Lt; label opaque = "no" userInteractionEnabled = "NO" contentMode = "left" horizontalHuggingPriority = "251" Urdhwadharhagingprioriti = "251" fixed frame = "yes" text = "label" Rekhabrekmod = "tail harness" baseline adjustment = "alignment punt" Adjusts fonticityfit = "no" translatessupercingmascinatecontentions = "no" id = "H9H-90-IFF" & gt; & Lt; Rect key = "frame" x = "15" y = "12" width = "252" height = "21" /> & Lt; FontDescription key = "fontDescription" type = "system" point size = "17" /> & Lt; Color key = "textColor" cocoaatechisti model color = "dark reader" /> & lt; Blue Key = "Highlight Chlor" /> & Lt; / Labels & gt; & Lt; / Subviews & gt; & Lt; / TableViewCellContentView & gt; & Lt; Connection & gt; & Lt; Outlet property = "label" destination = "H9h-90-Iff" id = "tmj-pZ-ad2" /> & Lt; / Connection & gt; & Lt; / TableViewCell & gt;  

Xcode 6.1 build6A1052d

If you are using prototype cells in a storyboard and define the contents and connections of the cell, you have to obtain a copy of that "ready" cell from the table view. You can not just create a new object of cell and expect it to work (you are getting a "trash" example without any connection)

What do you want to do, an identifier Setting is the prototype cell in the interface builder (this feature is in Inspector), to get a new instance of the cell, just:

  tableView.dequeueReusableCellWithIdentifier ("yourIdentifier") such as TableViewCell < / Code> 

In your case, call this Table making within view controller, just tableview.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -