我们有一个使用Storyboard的UIKit应用程序的Swift项目。一切都很好,直到我决定将应用程序的最低部署目标降低到iOS 7.构建应用程序时,我在ibtool中尝试编译故事板。错误是这样的:
2015-06-12 11:49:07.216 ibtoold[41058:6974134] [MT] DVTAssertions: ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilder/IDEInterfaceBuilder-7702/InterfaceBuilderKit/Connections/IBConnection.m:182
Details: Source and destination must be unique
Object: <IBCocoaTouchStoryboardPushSegue: 0x7fdea9bce8a0>
Method: -setDestination:
Thread: <NSThread: 0x7fdea2c07820>{number = 1, name = main}
Hints: None
Backtrace:
0 0x00000001015e0147 -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
1 0x00000001015dfb9f _DVTAssertionHandler (in DVTFoundation)
2 0x00000001015dfe8e _DVTAssertionFailureHandler (in DVTFoundation)
3 0x00000001023ff472 -[IBConnection setDestination:] (in IDEInterfaceBuilderKit)
4 0x00000001023fe5c9 +[IBConnection connectionWithSource:label:andDestination:] (in IDEInterfaceBuilderKit)
5 0x00000001086aa798 (in IDEInterfaceBuilderCocoaTouchIntegration)
6 0x0000000108704abb (in IDEInterfaceBuilderCocoaTouchIntegration)
7 0x0000000102481472 -[IBDocument updateConnectionsAfterEnablingOrDisablingConfigurations] (in IDEInterfaceBuilderKit)
8 0x0000000102482194 __35-[IBDocument disableConfigurations]_block_invoke (in IDEInterfaceBuilderKit)
9 0x0000000102481beb -[IBDocument maintainCanvasCentersWhileTransformingCanvasPositions:] (in IDEInterfaceBuilderKit)
10 0x000000010248209c -[IBDocument disableConfigurations] (in IDEInterfaceBuilderKit)
11 0x000000010868852c (in IDEInterfaceBuilderCocoaTouchIntegration)
12 0x0000000102497469 -[IBDocumentAutolayoutManager runBlockInNewArbitrationStackEntryWithBehavior:block:] (in IDEInterfaceBuilderKit)
13 0x000000010247de2b -[IBDocument modifyViewsInAutolayoutSafeWayDuring:] (in IDEInterfaceBuilderKit)
14 0x00000001086884e2 (in IDEInterfaceBuilderCocoaTouchIntegration)
15 0x000000010865d1e5 (in IDEInterfaceBuilderCocoaTouchIntegration)
16 0x000000010244628f -[IBDocument finishChangingTargetRuntimeInCompiledIntermediateDocument] (in IDEInterfaceBuilderKit)
17 0x00000001024a5811 __85-[IBDocumentCompiler invokeWithIntermediateDocumentOfTargetRuntime:alwaysCopy:block:]_block_invoke (in IDEInterfaceBuilderKit)
18 0x00000001024a55a9 -[IBDocumentCompiler invokeWithIntermediateDocument:] (in IDEInterfaceBuilderKit)
19 0x00000001024a574d -[IBDocumentCompiler invokeWithIntermediateDocumentOfTargetRuntime:alwaysCopy:block:] (in IDEInterfaceBuilderKit)
20 0x00000001026aa61c -[IBStoryboardDocumentCompiler compileWithOptions:error:] (in IDEInterfaceBuilderKit)
21 0x00000001024a5937 +[IBDocumentCompiler compileContentsOfDocument:options:error:] (in IDEInterfaceBuilderKit)
22 0x0000000102460550 __47-[IBDocument compiledPackageWithOptions:error:]_block_invoke (in IDEInterfaceBuilderKit)
23 0x0000000102498ee5 -[IBDocumentAutolayoutManager assertIfArbitrationIsScheduledDuring:] (in IDEInterfaceBuilderKit)
24 0x00000001024604a7 -[IBDocument compiledPackageWithOptions:error:] (in IDEInterfaceBuilderKit)
25 0x00000001013e9f0a (in ibtoold)
26 0x00000001013e6b40 (in ibtoold)
27 0x00000001013e9370 (in ibtoold)
28 0x00000001013ef233 (in ibtoold)
29 0x00000001013ef7b0 (in ibtoold)
30 0x00000001013ef683 (in ibtoold)
31 0x00000001013de60a (in ibtoold)
32 0x00000001013eee2c (in ibtoold)
33 0x00000001013ee074 (in ibtoold)
34 0x00007fff9289f5c9 start (in libdyld.dylib)
35 0x0000000000000002
Command /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool failed with exit code 255
我检查了所有的segues(他们很多)但我似乎没有看到错误。此外,当最低部署目标是8.x时,没有问题。
答案 0 :(得分:0)
注意 - 这一切都是通过手动将引用插座添加到UI元素而实现的。我发现我不需要这样做之后不久,并且只是简单地添加TAG
就是我所需要的,因为我只是希望能够以编程方式访问元素以隐藏/显示它({{3 }})。
总之...
不知道这是否一定适用于OP,但也许它会对googler有所帮助:
当我手动通过直接编辑.xib
的XML而不是使用界面构建器在故事板中添加引用插座时,我遇到了此错误。
原因:我想在我拥有的标签上添加一个引用插座。但是,当我使用&#34; New Referencing Outlet&#34;在界面构建器中,我想要的IBOutlet
没有显示在列表中。所以,我用锤子敲打它直到它起作用&#34;方法并决定在XML中手动添加引用插座。
引用插座如下所示:
<outlet property="nameOfTheVar" destination="9CH-Ow-gWo" id="8CH-Ow-hWo"/>
destination
是此元素的UI元素的ID,id
是引用插座的唯一ID。
<outlet>
应该是<connections>
元素的子元素(具体而言,它将我的UI元素连接到代码中的IBOutlet
)。我的<label>
有一个<connections>
元素,所以我在那里添加了插座。 这就是导致我的源和目标必须是唯一错误的原因。我想它不是一个出口,成为元素的孩子,它是一个出口。
因此,为了解决错误,我将<outlet>
从实际UI元素的子元素<connections>
元素移动到<connections>
元素那是该视图<viewController>
的孩子。
这是(高度缩写的)XML:
<viewController>
<layoutGuides />
<view>
<subviews>
<label id="9CH-Ow-gWo">
<connections>
<!-- dont put the outlet here -->
</connections>
</label>
</subviews>
</view>
<connections>
<!--put the outlet here! -->
<outlet property="nameOfTheVar" destination="9CH-Ow-gWo" id="8CH-Ow-hWo"/>
</connections>
</viewController>