我正在使用 Xcode 7。我在 View A 中编写了展开函数。我想从 View B 返回到 View A。当我退出时用 ctrl 拖动按钮时,不会出现任何展开函数。当我右键单击退出时,它是空的。我该如何解决它?或者我可以通过编程方式设置展开吗?
这是我的展开函数:
@IBAction func unwindToProductList(sender: UIStoryboardSegue) {
print("unwindToProductList called")
}
编辑:
我想我发现了这个问题,但不明白为什么 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/