IBOutlet not connecting in SWIFT

我是研究僧i 提交于 2019-12-11 13:16:49

问题


All,

I have this in swift

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    @IBOutlet var tableView: UITableView!

So if i go in the storyboard, I should be able to see that, and I should be able to connect it like this :

So I should be able to go to 'New Referencing Outlet' and drag it on the view controller (yellow tab at the top) and I should see 'tableView' and connect it. This doesn't happen , I am confused why !


回答1:


Do no type following line in advance.

@IBOutlet var tableView: UITableView! // <-- this line

Instead, add a UIComponent in your storyboard first and then using "assistant editor" drag the connection link in your swift file.




回答2:


On the picture you posted I can see you are looking for IBOutlet, but you selected the tableView not the whole controller.

Click on the white status bar (where yellow - controller and 2 oranges - responder and exit buttons are) then you will see your IBOutlet



来源:https://stackoverflow.com/questions/27060450/iboutlet-not-connecting-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!