我正在创建一个需要通知的应用程序。我创建了一个带有开关的设置页面,用于切换应用程序的通知。我尝试使用@IBAction 将开关链接到 ViewController2,但它一直将对象连接到 Exit,而不是 ViewController。我真的很沮丧,因为@IBAction 不会保持连接。我不确定发生了什么,但如果我能得到帮助,那就太棒了。
这些图像在下面链接到 Imigur。
我正在创建一个需要通知的应用程序。我创建了一个带有开关的设置页面,用于切换应用程序的通知。我尝试使用@IBAction 将开关链接到 ViewController2,但它一直将对象连接到 Exit,而不是 ViewController。我真的很沮丧,因为@IBAction 不会保持连接。我不确定发生了什么,但如果我能得到帮助,那就太棒了。
这些图像在下面链接到 Imigur。
问题可能是您假设您可以形成从一个视图控制器场景中的 UISwitch 到另一个视图控制器的操作连接。你不能。您只能在情节提要的同一场景内的视图控制器和界面之间形成出口和动作。
Click on the top bar of your problematic ViewController (the overview of what is getting displayed on screen), click the top left icon (called View Controller).
On the right click "Show The Identity Inspector" icon and you should see class. Change the text to 'ViewController'. Hopefully it should auto fill.
This will solve the problem.