ios - UIButton 在 NavigationController 中没有响应

标签 ios swift xcode

我创建了一个 XIB 文件,xib 文件中有一个 NavigationController,NavigationController 中有一个 UIViewController。然后我将一个按钮拖到 UIViewController 中。我想连接按钮和 UIViewController 但我不能。我只能从按钮拖一条线到 navigationController,而按钮不响应 NavigationController 中的操作。我不知道为什么。

谁能告诉我为什么?我想知道为什么我无法连接按钮和我的 UIViewController(只能连接到 NavigationController)。如何让按钮起作用?

enter image description here

enter image description here

enter image description here

最佳答案

我遇到过类似的问题。你有几个选择。

First you can find the button (or label in my case) on the left side of the storyboard and you can right click then drag to the code in the assistant editor

enter image description here

You could go into the assistant editor where the Action or Outlet is, find the circle next to it, left click and drag to the button or label in the list view that I showed before.

enter image description here

And the other option is to find the item you want to link in the storyboard and select it. Then select the 'Selections Inspector on the top right. In there you can click and drag from the circle and see everything that is connected. You can also see EVERYTHING in the VC if you select the ViewController in the story board and look at the Selections Inspector.

enter image description here

关于ios - UIButton 在 NavigationController 中没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48981133/

相关文章:

ios - Xcode 6 - 将 segue 推送到同一个 View Controller

ios - layoutIfNeeded 内的代码被调用两次

objective-c - 无法识别的选择器已发送到实例IOS 10

ios - 如何从 UIViewController 中删除外部 UIViews?

ios - 葫芦 iOS : how to get value using query command

ios - 关闭两个 View Controller 然后推送一个 View Controller - Swift

ios - Swift 框架可以引用另一个 Swift 框架的类扩展吗?

swift - 如何从 Podspec 自动安装第 3 方框架

swift - 不安全的可变寻址器崩溃

使用字典键和值将数据加载到 UITableView 时出现 Swift 问题