storyboard - xcode 7 退出时未出现展开

标签 storyboard swift2 xcode7.2

我正在使用 Xcode 7。我在 View A 中编写了展开函数。我想从 View B 返回到 View A。当我退出时用 ctrl 拖动按钮时,不会出现任何展开函数。当我右键单击退出时,它是空的。我该如何解决它?或者我可以通过编程方式设置展开吗?

这是我的展开函数:

@IBAction func unwindToProductList(sender: UIStoryboardSegue) {
    print("unwindToProductList called")
}

enter image description here

编辑:

我想我发现了这个问题,但不明白为什么 xcode 会这样。在我的 View Controller 的开头,我有以下代码行:

import UIKit

extension ProductListViewController: UISearchResultsUpdating {
    func updateSearchResultsForSearchController(searchController: UISearchController) {
        filterContentForSearchText(searchController.searchBar.text!)
    }
}

class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
.....
}

当我注释我的扩展时,退出时会看到我的展开函数,但是如果取消注释我的扩展,退出时不会再次看到我的展开函数,我是否在错误的位置写了扩展?

解决方案:

我通过从代码开头删除扩展名并在 View Controller 中实现它来解决我的问题,退出按钮开始看到我的展开功能:

class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating {

    func updateSearchResultsForSearchController(searchController: UISearchController) {
        filterContentForSearchText(searchController.searchBar.text!)
    }

    ....
}

最佳答案

我通过从代码开头删除扩展名并在 View Controller 中实现它来解决我的问题,退出按钮开始看到我的展开功能:

class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating {

    func updateSearchResultsForSearchController(searchController: UISearchController) {
        filterContentForSearchText(searchController.searchBar.text!)
    }

    ....
}

关于storyboard - xcode 7 退出时未出现展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35394506/

相关文章:

swift - 通过覆盖 init 从 Storyboard初始化 View Controller

ios - Swift 中的 IBDesignable 和多个目标

ios - 代码=exc_i386_invop 子代码=0x0 nib xcode7.2

iphone - UITableViewCell 显示 UIImageView 或 UIProgressView

ios - 文档 Main.storyboard 需要 Xcode 8.0 或更高版本

swift - 在 Alamofire Swift 2.2 中使用 completionHandler

ios - 如何根据条件以编程方式移动到 tableViewController 或 viewController

ios - 转至 UIViewController 而不初始化新对象

用swift 3.0编译的IOS Charts Module不能导入Swift 2.3