我正在我的应用页面上工作,用户从UITableView中选择3个单元格中的一个,并被带到2个UIViewControllers中的相应1个,该页面填充了包含所选单元格详细信息的页面。我正在尝试准备我的故事板来执行此操作,并执行“与SeseWithIdentifier()相关联”。我通过使用' show'连接父视图的视图控制器和每个子视图的视图来创建一个segue。方法。然后我将其添加到我的父视图控制器:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let appDelegate = (UIApplication.sharedApplication().delegate as AppDelegate)
if indexPath.row == 0 {
appDelegate.selected = 1
self.performSegueWithIdentifier("GraphID", sender: self)
}
if indexPath.row == 1 {
appDelegate.selected = 2
self.performSegueWithIdentifier("DistanceID", sender: self)
}
if indexPath.row == 2 {
appDelegate.selected = 3
self.performSegueWithIdentifier("GraphID", sender: self)
}
}
当我启动我的应用程序并按任何单元格时,它会因NSException而崩溃:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<FlightTracker.StatusViewController: 0x7fe4faa5c8c0>) has no segue with identifier 'DistanceID''
*** First throw call stack:
(
0 CoreFoundation 0x0000000109446f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001090dfbb7 objc_exception_throw + 45
2 UIKit 0x0000000109b9dd3b -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 UIKit 0x00000001174dec78 -[UIViewControllerAccessibility performSegueWithIdentifier:sender:] + 39
4 FlightTracker 0x0000000106f977e2 _TFC13FlightTracker20StatusViewController9tableViewfS0_FTCSo11UITableView23didSelectRowAtIndexPathCS o11NSIndexPath_T_ + 2530
5 FlightTracker 0x0000000106f97cef _TToFC13FlightTracker20StatusViewController9tableViewfS0_FTCSo11UITableView23didSelectRowAtIndexPathCSo11NSIndexPath_T_ + 79
6 UIKit 0x0000000109b5e393 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1293
7 UIKit 0x0000000109b5e4d4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
8 UIKit 0x0000000109a99331 _applyBlockToCFArrayCopiedToStack + 314
9 UIKit 0x0000000109a991ab _afterCACommitHandler + 516
10 CoreFoundation 0x000000010937bdc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
11 CoreFoundation 0x000000010937bd20 __CFRunLoopDoObservers + 368
12 CoreFoundation 0x0000000109371b53 __CFRunLoopRun + 1123
13 CoreFoundation 0x0000000109371486 CFRunLoopRunSpecific + 470
14 GraphicsServices 0x000000010b1ba9f0 GSEventRunModal + 161
15 UIKit 0x0000000109a76420 UIApplicationMain + 1282
16 FlightTracker 0x0000000106fac07e top_level_code + 78
17 FlightTracker 0x0000000106fac0ba main + 42
18 libdyld.dylib 0x000000010bdc5145 start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我是否正确连接了故事板以使用此方法?
答案 0 :(得分:1)
在您发布的照片中,您正在设置StoryboardID调用DistanceID
。这与我们正在讨论的segue identifier
完全不同。
因此,请在viewControllers之间选择segue
,并将标识符更改为DistanceID
。这是正确的标识符。