Ios Xcode 8.1和展开段有问题
我无法使用最新的Ios Xcode 8.1和展开段有问题,ios,swift,xcode,segue,unwind-segue,Ios,Swift,Xcode,Segue,Unwind Segue,我无法使用最新的Xcode 8.1GM来轻松工作。我只是想知道是我一个人,还是其他人也有同样的经历。我像以前一样设置了视图控制器,它在Xcode8.0中工作,但现在我运气不好。试着清洁等等,但没有任何帮助。我希望在我提交雷达之前,其他人也能测试一下 首先实例化视图控制器的视图控制器具有以下代码: @IBAction func unwindToSettingsTableViewController(_ segue: UIStoryboardSegue) { print("unwind")
Xcode 8.1
GM来轻松工作。我只是想知道是我一个人,还是其他人也有同样的经历。我像以前一样设置了视图控制器,它在Xcode
8.0中工作,但现在我运气不好。试着清洁等等,但没有任何帮助。我希望在我提交雷达之前,其他人也能测试一下
首先实例化视图控制器的视图控制器
具有以下代码:
@IBAction func unwindToSettingsTableViewController(_ segue: UIStoryboardSegue) {
print("unwind")
}
我也尝试过不加下划线,但没有帮助。
设置此选项时,应能够ctrl
从“文件所有者”拖动以退出,并设置展开顺序:
所以要么我做得完全错误(我不这么认为,它以前工作得非常好),要么是Xcode 8.1中有一个bug
我试着在一个新项目中做同样的事情,然后它正常工作了。所以我猜我的项目或故事板文件有问题
更新
由于故事板包含相当小的场景,我只是删除了它,然后重新创建它,使用相同的视图控制器类等等。现在它开始工作了。因此,拥有完全相同的代码,但有一个新的故事板,让我觉得这是一个bug。今天早上同样的事情发生在我身上。我的问题是,我创建的@iAction被翻译成了具有不同名称的故事板,在您的情况下,它将是:
“取消设置TableViewControllerWithSegue”
我所做的是删除属性检查器中的“with segue”部分,一切都按预期进行。我不知道这是不是一个bug,或者这是发生在你身上的事情
希望有帮助。我找到了这种奇怪行为的原因。需要对我们如何构建应用程序进行一点解释,以了解如何和为什么
首先,我们倾向于将它们分割成更小的块,而不是使用大的ViewController。这样,我们总是知道“业务逻辑”在哪里,数据源在哪里,出口和操作在哪里,等等。典型的TableViewController如下所示:
SampleTVC.swift
class SampleTableViewController: UITableViewController {
@IBOutlet var someLabel: UILabel!
@IBOutlet var someButton: UIButton!
@IBAction func unwindHere(_ segue: UIStoryBoardSegue) {
doSomething()
}
}
extension SampleTableViewController {
override func numberOfSections(in tableView: UITableView) -> Int
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
}
extension SampleTableViewController: NSFetchedResultsControllerDelegate {
var fetchedResultsController: NSFetchedResultsController<Item>
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
}
SampleDelegate+DataSource.swift
class SampleTableViewController: UITableViewController {
@IBOutlet var someLabel: UILabel!
@IBOutlet var someButton: UIButton!
@IBAction func unwindHere(_ segue: UIStoryBoardSegue) {
doSomething()
}
}
extension SampleTableViewController {
override func numberOfSections(in tableView: UITableView) -> Int
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
}
extension SampleTableViewController: NSFetchedResultsControllerDelegate {
var fetchedResultsController: NSFetchedResultsController<Item>
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
}
SampleFetchedResultsController.swift
class SampleTableViewController: UITableViewController {
@IBOutlet var someLabel: UILabel!
@IBOutlet var someButton: UIButton!
@IBAction func unwindHere(_ segue: UIStoryBoardSegue) {
doSomething()
}
}
extension SampleTableViewController {
override func numberOfSections(in tableView: UITableView) -> Int
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
}
extension SampleTableViewController: NSFetchedResultsControllerDelegate {
var fetchedResultsController: NSFetchedResultsController<Item>
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)
}
扩展SampleTableViewController:NSFetchedResultsControllerDelegate{
var fetchedResultsController:NSFetchedResultsController
func controllerWillChangeContent(\ucontroller:NSFetchedResultsController)
func控制器(控制器:NSFetchedResultsController,didChange sectionInfo:NSFetchedResultsSectionInfo,atSectionIndex sectionIndex:Int,类型:NSFetchedResultsChangeType)
func控制器(controller:NSFetchedResultsController,didChange anObject:Any,在indexPath:indexPath?处,对于类型:NSFetchedResultsChangeType,newIndexPath:indexPath?)
func controllerDidChangeContent(\控制器:NSFetchedResultsController)
}
我试着在这里把代码连接到一个由这些较小的比特组成的TVC上,但是没有办法,没有倒带序列弹出
因此,将所有扩展名与SampleTableViewController放在同一个文件中,仍然不起作用
解决方案是删除所有扩展,并将所有函数放入类本身,然后它就可以正常工作了。这没有多大意义,它显然是一个bug。我的项目也有同样的问题,但它似乎是一个项目范围内的bug
我可以创建一个新项目,创建一个展开序列没有问题,但即使在我当前的项目中创建一个新的故事板,只有NavigationController和两个ViewController,退出按钮上也不会显示回放序列
这是一个非常恼人的错误,因为它使我的项目急停。谢谢你的提示。这对我没有多大帮助,但至少我知道我不是唯一一个必须与故事板抗争的人。如果你读了这个问题,你会看到我确实从文件所有者那里拖出并退出,屏幕截图中也显示了同样的情况。您以编程方式添加视图的想法是错误的。从故事板连接时,它工作正常。对我来说,只需将扩展名移回同一个文件就可以解决问题。显然是一个可怕的错误。希望很快就能修复。我根本就不使用segues,而是选择了Chris Eidhof和Florian Kugler在Objc.io Swift Talk第五集中解释的流协调器模型@GJNilsen,这个愚蠢的错误仍然存在于xCode 8.3.3中!!。。我也遇到了同样的问题,从零开始了很多次,结果发现在类本身中移动扩展类最终允许我通过Ctrl+拖动退出来进行一段放松的过程……这真的很烦人