我正在使用 Xcode 7。我在视图 A 中编写了展开函数。我想从视图 B 返回到视图 A。当我在退出时使用 ctrl 拖动按钮时,没有出现任何展开函数。当我右键单击退出时,它是空的。我该如何解决?或者我可以以编程方式设置展开?
这是我的放松功能:
@IBAction func unwindToProductList(sender: UIStoryboardSegue) {
print("unwindToProductList called")
}
编辑:
我想我发现了这个问题,但不明白为什么 xcode 会那样做。在我的视图控制器的开头,我有以下代码行:
import UIKit
extension ProductListViewController: UISearchResultsUpdating {
func updateSearchResultsForSearchController(searchController: UISearchController) {
filterContentForSearchText(searchController.searchBar.text!)
}
}
class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
.....
}
当我评论我的扩展时,退出看到我的展开功能,但是如果取消评论我的扩展,退出不再看到我的展开功能,我是不是在错误的地方写了扩展?
解决方案:
我通过从代码开头删除扩展名并在视图控制器中实现它来解决我的问题,在它退出按钮开始看到我的展开功能之后:
class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating {
func updateSearchResultsForSearchController(searchController: UISearchController) {
filterContentForSearchText(searchController.searchBar.text!)
}
....
}