Xcode Interface Builder 在我编辑故事板时崩溃

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12580881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:37:49  来源:igfitidea点击:

Xcode Interface Builder crashes when I edit storyboard

xcodecrashinterface-builder

提问by James

I'm new to Xcode and am having problems with the IDE crashing when I use the Interface Builder. This is Xcode 4.5.

我是 Xcode 的新手,在使用 Interface Builder 时遇到了 IDE 崩溃的问题。这是 Xcode 4.5。

It worked properly for long enough for me to add a dozen or so buttons to the storyboard -- but when I try to resize any of them, it crashes and quits. If I move a button, it crashes. If I add a new object like a label, it sometimescrashes, but not always.

它正常工作了足够长的时间,我可以在故事板中添加十几个按钮 - 但是当我尝试调整其中任何一个的大小时,它会崩溃并退出。如果我移动一个按钮,它就会崩溃。如果我添加一个像标签这样的新对象,它有时会崩溃,但并非总是如此。

If I don't try to edit the storyboard, the project builds and runs on the simulator with no problems.

如果我不尝试编辑情节提要,该项目将在模拟器上构建和运行,不会出现任何问题。

I've pasted what looks like the relevant part of the crash report below. To save space, I've deleted everything from the 'view hierarchy' section downwards, but I can add it if it's useful. All the crash reports refer to the same error.

我在下面粘贴了崩溃报告的相关部分。为了节省空间,我从“视图层次结构”部分向下删除了所有内容,但如果有用,我可以添加它。所有的崩溃报告都指向同一个错误。

Interestingly, when I look at the Console log, there's another report from Interface Builder before each of these crashes:

有趣的是,当我查看控制台日志时,在每次崩溃之前,Interface Builder 都会提供另一个报告:

25/09/2012 10:46:35.661 Interface Builder Cocoa Touch Tool: CFPreferences:
user home directory at file://localhost/Users/me/Library/Application Support/
iPhone Simulator/User/ is unavailable. User domains will be volatile.

It's correct -- that directory doesn't exist. I've got iPhone Simulator/6.0, but nothing else. I'm logged in as the user in that path.

没错——那个目录不存在。我有 iPhone Simulator/6.0,但没有别的。我以该路径中的用户身份登录。

Based on other suggestions on Stack Overflow and elsewhere, I've tried cleaning the build then deleting the entire iPhone Simulator directory and letting the simulator recreate it, but that makes no difference.

根据 Stack Overflow 和其他地方的其他建议,我尝试清理构建,然后删除整个 iPhone Simulator 目录并让模拟器重新创建它,但这没有区别。

As an experiment, I've just created a new Project and dragged some buttons and labels into the storyboard. That seems fine. No crashes.

作为一项实验,我刚刚创建了一个新项目并将一些按钮和标签拖到故事板中。这似乎很好。没有崩溃。

Does that suggest that something has got corrupted in my other project?

这是否表明我的其他项目中的某些内容已损坏?

Any suggestions would be very welcome. This is not an important project -- I'm learning my way around at this stage -- but if something is causing problems then I want to sort it out before I start any serious work in Xcode.

任何建议将非常受欢迎。这不是一个重要的项目——我在这个阶段正在学习我的方法——但是如果有什么问题导致了问题,那么我想在我开始在 Xcode 中开始任何认真的工作之前把它整理出来。

Thanks in advance.

提前致谢。

James

詹姆士

Process:         Xcode [650]
Path:            /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:      com.apple.dt.Xcode
Version:         4.5 (1839)
Build Info:      IDEApplication-1839000000000000~3
App Item ID:     497799835
App External ID: 10747437
Code Type:       X86-64 (Native)
Parent Process:  launchd [129]

Date/Time:       2012-09-25 10:46:43.202 +0100
OS Version:      Mac OS X 10.7.5 (11G56)
Report Version:  9

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
ProductBuildVersion: 4G182
ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilderCocoaTouch/IDEInterfaceBuilderCocoaTouch-1926/IBPlugin/Utilities/IBObjectMarshalling.m:651
Details:  Failed to arbitrate IBNSLayoutConstraint, IBUIButton, IBUILabel, IBUIView, and IBUIViewController.

Interface Builder encountered an error communicating with the iOS Simulator. If you choose to file a crash report or radar for this issue, please check Console.app for crash reports for "Interface Builder Cocoa Touch Tool" and include their content in your crash report.

Exception name: IBAssertionFailure
Exception reason: ASSERTION FAILURE: 
Reason:     All views needing candidate constraints have already had constraints generated. This most likely indicates a bug involving layout of the following views:
Layout engine frame ({{20, 60}, {282, 57}}) of <UILabel: 0xb36f590; frame = (20 60; 281 57); text = '0'; clipsToBounds = YES; opaque = NO; autoresize = TM+BM; userInteractionEnabled = NO; layer = <CALayer: 0xb36f620>> does not match canvas frame ({{20, 60}, {281, 57}})
Layout engine frame ({{236, 328}, {66, 43}}) of <UIRoundedRectButton: 0xb384590; frame = (236 328; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb384660>> does not match canvas frame ({{236, 328}, {65, 43}})
Layout engine frame ({{236, 124}, {66, 43}}) of <UIRoundedRectButton: 0xb38ea10; frame = (236 124; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb38eae0>> does not match canvas frame ({{236, 124}, {65, 43}})
Layout engine frame ({{236, 175}, {66, 43}}) of <UIRoundedRectButton: 0xb390a30; frame = (236 175; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb36e8e0>> does not match canvas frame ({{236, 175}, {65, 43}})
Layout engine frame ({{236, 226}, {66, 43}}) of <UIRoundedRectButton: 0xb392a90; frame = (236 226; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb392b60>> does not match canvas frame ({{236, 226}, {65, 43}})
Layout engine frame ({{236, 277}, {66, 43}}) of <UIRoundedRectButton: 0xb394b70; frame = (236 277; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb394c40>> does not match canvas frame ({{236, 277}, {65, 43}})

回答by James

Update: Further experimentation revealed the 'Use Autolayout' checkbox for the storyboard. Switching this off then saving the file seems to have fixed the problem. I can edit at will, with no more crashes.

更新:进一步的实验揭示了故事板的“使用自动布局”复选框。关闭它然后保存文件似乎已经解决了这个问题。我可以随意编辑,不再出现崩溃。

回答by Phil Scarf

When xib files are in different formats, but are all in the same project, this will happen. In my case, some xib files were compatible for xcode5 dp, but others were for xcode 4.6

当xib 文件的格式不同,但都在同一个项目中时,就会发生这种情况。就我而言,一些 xib 文件兼容 xcode5 dp,但其他文件兼容 xcode 4.6

The object here is to look for differences in xib files

这里的目的是寻找xib文件中的差异

Hope this helps people in the future!

希望这对未来的人们有所帮助!

回答by eljoe

I got this error aswell, for me the problem was a TableView that had some constraints left. After deleting all constraints the error stopped showing up.

我也遇到了这个错误,对我来说问题是一个 TableView 有一些约束。删除所有约束后,错误停止显示。

回答by gruvin

This problem likely has something to do with the now two different sized iPhone retina displays (3.5" and 4") and how that interacts with a view's Mode:Scale To Filland perhaps Autosize Subviews, also -- both of which are enabled by default.

这个问题可能与现在两种不同尺寸的 iPhone 视网膜显示器(3.5" 和 4")有关,以及它们如何与视图的Mode:Scale To FillAutosize Subviews 交互——这两者都是默认启用的.

For example, in my case I had a 4" retina sized MainView with tightly packed button views. But the emulator was set to 3.5 retina display. Because my button views were only 43x43px in size and spaced right next to each other, this would cause the button positions to auto-down-scale in such a way that they overlapped, when their positions were adjusted for the 3.5" display (Scale To Filla smallerspace) -- since they could not shrink in size. This overlapping of views seems likely to cause problems in the auto layout system. Hence the crash, I think.

例如,在我的例子中,我有一个 4" 视网膜大小的 MainView,带有紧密的按钮视图。但是模拟器设置为 3.5 视网膜显示。因为我的按钮视图大小只有 43x43px 并且彼此相邻,这会导致按钮位置自动向下缩放以这样一种方式,他们重叠,当他们的位置被调整为3.5"显示屏(缩放以填充一个较小的空间) -因为他们无法尺寸的缩小。这种视图重叠似乎可能会导致自动布局系统出现问题。因此,我认为崩溃。

This will also no doubt be why there is some reference to communicating with the emulator in the crash report, even though we're only working in Interface Builder, which did not previously seem intuitive.

毫无疑问,这也是为什么在崩溃报告中提到与模拟器通信的原因,即使我们只在 Interface Builder 中工作,这在以前看起来并不直观。