也许嵌入segue已经解雇过一次或者以编程方式添加了子视图?

时间:2015-12-11 08:11:01

标签: swift2.1 xcode7.1

我的代码因此NSException而崩溃

  

2015-12-11 16:43:23.170十二[3901:318168] ***断言失败 - [UIStoryboardEmbedSegueTemplate newDefaultPerformHandlerForSegue:],/ BuildRoot / Library / Cache / com.apple.xbs / Source / UIKit_Sim / UIKit -3512.29.5 / UIStoryboardEmbedSegueTemplate.m:35

并且AppDelegate行冻结了红线

class AppDelegate: UIResponder, UIApplicationDelegate {

这是我的设置:

enter image description here ViewController.swift

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    switch (segue.identifier!) {
    case "topSeg":
        segue.destinationViewController as? SafetyVC
    case "mainBtSeg":
        segue.destinationViewController as? MainBtVC
    default:
        break
    }

以下块中的最后一行是崩溃应用程序的行:

extension ViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return rows.count
}


func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    performSegueWithIdentifier("mainBtSeg", sender: nil)

这是LogCat:



2015-12-12 03:25:21.387 twelve[4451:372407] *** Assertion failure in -[UIStoryboardEmbedSegueTemplate newDefaultPerformHandlerForSegue:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29.5/UIStoryboardEmbedSegueTemplate.m:35
2015-12-12 03:25:21.394 twelve[4451:372407] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There are unexpected subviews in the container view. Perhaps the embed segue has already fired once or a subview was added programmatically?'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010ded3f45 __exceptionPreprocess + 165
	1   libobjc.A.dylib                     0x000000010fe1fdeb objc_exception_throw + 48
	2   CoreFoundation                      0x000000010ded3daa +[NSException raise:format:arguments:] + 106
	3   Foundation                          0x000000010e5445ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
	4   UIKit                               0x000000010f252a60 __67-[UIStoryboardEmbedSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 444
	5   UIKit                               0x000000010f0377c4 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 460
	6   UIKit                               0x000000010f0375c7 -[UIStoryboardSegueTemplate _perform:] + 82
	7   UIKit                               0x000000010eaad938 -[UIViewController performSegueWithIdentifier:sender:] + 99
	8   twelve                              0x000000010dce8084 _TFC6twelve14ViewController9tableViewfS0_FTCSo11UITableView23didSelectRowAtIndexPathCSo11NSIndexPath_T_ + 132
	9   twelve                              0x000000010dce831f _TToFC6twelve14ViewController9tableViewfS0_FTCSo11UITableView23didSelectRowAtIndexPathCSo11NSIndexPath_T_ + 79
	10  UIKit                               0x000000010ea58a21 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1968
	11  UIKit                               0x000000010ea58c76 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 388
	12  UIKit                               0x000000010e9241ba _runAfterCACommitDeferredBlocks + 317
	13  UIKit                               0x000000010e937396 _cleanUpAfterCAFlushAndRunDeferredBlocks + 95
	14  UIKit                               0x000000010e9431c2 _afterCACommitHandler + 90
	15  CoreFoundation                      0x000000010ddff947 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	16  CoreFoundation                      0x000000010ddff8b7 __CFRunLoopDoObservers + 391
	17  CoreFoundation                      0x000000010ddf550b __CFRunLoopRun + 1147
	18  CoreFoundation                      0x000000010ddf4e08 CFRunLoopRunSpecific + 488
	19  GraphicsServices                    0x0000000113411ad2 GSEventRunModal + 161
	20  UIKit                               0x000000010e91830d UIApplicationMain + 171
	21  twelve                              0x000000010dce992d main + 109
	22  libdyld.dylib                       0x000000011092792d start + 1
	23  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 




由于

1 个答案:

答案 0 :(得分:-3)

对于可能需要此问题帮助的任何人,我的解决方案是在我自己的类中为我的自定义覆盖viewLoad添加[super viewLoad]