IBOutlet not connecting in SWIFT

2019-07-24 23:06发布

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 :

enter image description here

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 !

2条回答
聊天终结者
2楼-- · 2019-07-24 23:06

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

查看更多
Animai°情兽
3楼-- · 2019-07-24 23:29

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.

enter image description here

查看更多
登录 后发表回答