On my first view controller I had no problem creating IBOutlets and Actions, but when I made another view controller, I couldn't make an IBOutlet. There was no blue line when I control dragged it and I couldn't make an IBOutlet and then connect it up either. The first view controller still works. Is it possible to make IBOutlets on two different view controller?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Your view controller must have a custom class file assigned to it in the identity inspector in InterfaceBuilder:
Then select the assistant editor and you should be able to ctrl-drag IBOutlets to the associated swift file.
回答2:
Make sure you have set the custom class for second view controller in your storyboard.
回答3:
it happens to me sometimes as well... and the reason it to use the new controller you need to create a new view controller file for it where you can use the iboutlets generally.. so you will be having one view controller file for each view controller. and you can follow the steps to do that.
- first of all delete the new view controller file if you have made any. and the new controller as well...
- go to file new file choose cocoa class and then next and then write the name of the class you want e.g. newcontroller and make sure you choose uiviewcontroller in the next option and then click next and create.
- create a new vie controller in the main.storyboard and then click on the new view controller and on the right hand side rename the class to newcontroller. once you Finnish all these three steps you will be able to use iboutlets for sure..
good luck..