在我的应用程序中,我设置了 UIView 的约束,其高度是使用宽高比约束从其宽度计算得出的。它在 iOS8 上完美适用于各种设备屏幕尺寸(3.5、4、4.7、5.5),但它会导致应用程序在每台 iOS7 设备上崩溃。
我假设这是宽高比约束,因为如果我用固定高度约束替换它,它就不会再崩溃(显然它在某些设备上看起来很糟糕)。
堆栈跟踪非常长,所以我只复制其中的一部分。
预先感谢您的帮助!
Objective: {objective 0x7f9d90da33c0: <750:4692, 251:2936, 250:367> + <251:-1>*0x7f9d90c06220.marker{id: 592} + <251:-1>*0x7f9d90c24420.marker{id: 599} + <251:-1>*0x7f9d90c25650.marker{id: 594} + <251:-1>*0x7f9d90c27ad0.marker{id: 597} + <750:-1>*0x7f9d90c3b270.marker{id: 483} + <250:-3.9875>*0x7f9d90c43e40.marker{id: 618} + <250:-3.9875>*0x7f9d90c43e90.marker{id: 620} + <750:-4>*0x7f9d90c442e0.marker{id: 479} + <251:1>*0x7f9d90c464b0.marker{id: 485} + <251:-1>*0x7f9d90c46bf0.marker{id: 504} + <251:-1>*0x7f9d90c46c90.marker{id: 508} + <251:-1>*0x7f9d90c46ce0.marker{id: 510} + <251:-1>*0x7f9d90c46d80.marker{id: 514} + <251:-2>*0x7f9d90c4aa60.marker{id: 623} + <251:-2>*0x7f9d90c4aab0.marker{id: 625} + <251:-2, 250:-3.9875>*0x7f9d90c4ab50.marker{id: 631} + <251:-2, 250:-3.9875>*0x7f9d90c4abf0.marker{id: 634} + <251:4, 250:3.9875>*0x7f9d90c4ac40.marker{id: 637} + <251:4, 250:3.9875>*0x7f9d90c4ac90.marker{id: 642} + <750:1, 251:1>*0x7f9d90c4c530.negError{id: 645} + <750:1, 251:1>*0x7f9d90c4cb20.posErrorMarker{id: 646} + <750:1, 251:1>*0x7f9d90c530f0.negError{id: 649} + <750:1, 251:1>*0x7f9d90c53150.negError{id: 651} + <750:1, 250:1>*0x7f9d90c53820.posErrorMarker{id: 652} + <750:1, 250:1>*0x7f9d90c538a0.posErrorMarker{id: 654} + <750:1, 250:1>*0x7f9d90c53fd0.posErrorMarker{id: 656} + <750:1, 250:1>*0x7f9d90c54070.posErrorMarker{id: 658} + <750:1, 251:1>*0x7f9d90c54650.negError{id: 661} + <750:1>*0x7f9d90c546b0.negError{id: 663} + <251:1>*0x7f9d90c546b0.posErrorMarker{id: 662} + <750:1>*0x7f9d90c55230.negError{id: 665} + <251:1>*0x7f9d90c55230.posErrorMarker{id: 664} + <750:1, 251:1>*0x7f9d90c552b0.negError{id: 667} + <750:1, 251:1>*0x7f9d90d34300.posErrorMarker{id: 916} + <750:1>*0x7f9d90de48a0.marker{id: 738} + <250:-1>*0x7f9d90de48f0.marker{id: 740} + <250:-1>*0x7f9d90de4940.marker{id: 744} + <750:1>*0x7f9d90de4990.marker{id: 745} + <750:1>*0x7f9d90de4c70.marker{id: 718} + <750:1>*0x7f9d90de4cc0.marker{id: 720} + <250:-1
...
Integralization Adjustments:
0x7f9d93042a90.marker{id: 532} [<NSLayoutConstraint:0x7f9d93042a90 UIView:0x7f9d9303d590.width == 1.50943*UIView:0x7f9d9303d590.height>] -> 0.132066
0x7f9d93042c70.marker{id: 546} [<NSLayoutConstraint:0x7f9d93042c70 UIButton:0x7f9d90de27a0.height == UIButton:0x7f9d93018ab0.height>] -> 1.000000
0x7f9d93042d60.marker{id: 552} [<NSLayoutConstraint:0x7f9d93042d60 UIButton:0x7f9d9303dbf0.width == UIButton:0x7f9d93018ab0.width>] -> -1.000000
0x7f9d93042db0.marker{id: 554} [<NSLayoutConstraint:0x7f9d93042db0 UIButton:0x7f9d9303dbf0.height == UIButton:0x7f9d93033b40.height>] -> 1.000000
0x7f9d93042ea0.marker{id: 562} [<NSLayoutConstraint:0x7f9d93042ea0 UIButton:0x7f9d93033b40.width == UIButton:0x7f9d9303c500.width>] -> -1.000000
0x7f9d930431c0.marker{id: 581} [<NSLayoutConstraint:0x7f9d930431c0 UIButton:0x7f9d9303c500.height == UIButton:0x7f9d93045880.height>] -> 1.000000
Statistics:
195 rows. Variable counts:
1 -> 59
2 -> 28
3 -> 3
4 -> 7
5 -> 4
6 -> 3
7 -> 3
8 -> 4
9 -> 8
10 -> 10
11 -> 11
12 -> 10
13 -> 7
14 -> 2
15 -> 3
16 -> 10
17 -> 17
18 -> 6
}: internal error. Cannot find an outgoing row head for incoming head UIView:0x7f9d930332a0.Height{id: 981}, which should never happen.'
*** First throw call stack:
(
0 CoreFoundation 0x000000011284d495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000011220699e objc_exception_throw + 43
2 CoreFoundation 0x000000011284d2ad +[NSException raise:format:] + 205
3 Foundation 0x0000000110dfb054 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 178
4 Foundation 0x0000000110dfaf22 -[NSISEngine optimize] + 147
5 Foundation 0x0000000110f432e3 -[NSISEngine withBehaviors:performModifications:] + 192
6 UIKit 0x000000011126f889 -[UIView(Hierarchy) _postMovedFromSuperview:] + 321
7 UIKit 0x000000011126df42 __UIViewWasRemovedFromSuperview + 206
8 UIKit 0x000000011126db9e -[UIView(Hierarchy) removeFromSuperview] + 218
9 UIKit 0x0000000111330069 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 320
10 UIKit 0x0000000111328fdd __49-[UINavigationController _startCustomTransition:]_block_invoke + 138
11 UIKit 0x000000011187ec2a -[_UIViewControllerTransitionContext completeTransition:] + 78
12 UIKit 0x0000000111211da4 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke103 + 605
13 UIKit 0x00000001112746e8 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 299
14 UIKit 0x000000011126068e -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 235
15 UIKit 0x0000000111260941 -[UIViewAnimationState animationDidStop:finished:] + 78
16 UIKit 0x000000011ef6d4b7 -[UIViewAnimationStateAccessibility(SafeCategory) animationDidStop:finished:] + 48
17 QuartzCore 0x0000000110ac9134 _ZN2CA5Layer23run_animation_callbacksEPv + 310
18 libdispatch.dylib 0x000000011327772d _dispatch_client_callout + 8
19 libdispatch.dylib 0x00000001132673fc _dispatch_main_queue_callback_4CF + 354
20 CoreFoundation 0x00000001128ab289 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
21 CoreFoundation 0x00000001127f8854 __CFRunLoopRun + 1764
22 CoreFoundation 0x00000001127f7d83 CFRunLoopRunSpecific + 467
23 GraphicsServices 0x0000000114223f04 GSEventRunModal + 161
24 UIKit 0x000000011121be33 UIApplicationMain + 1010
25 Playchat 0x000000010fa89513 main + 115
26 libdyld.dylib 0x00000001134fa5c9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
最佳答案
这是一个烦人的错误,也让我浪费了很多时间。我遇到了完全相同的问题,该应用程序在 iOS 8 中运行良好,但在 iOS 7.1 中崩溃了。问题是 ScrollView 的纵横比约束。在尝试了很多不同的东西之后,这终于解决了问题:
崩溃似乎是浮点计算在某个时候失败的结果。在我的例子中,我定义了 16:9 或 9:16 的纵横比,即 0.5625。 将乘数从 0.5625 更改为 0.5624 解决了问题,此后没有再出现崩溃。
关于iOS 宽高比约束在 iOS7 上失效,适用于 iOS8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28111635/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我已经在Sinatra上创建了应用程序,它代表了一个简单的API。我想在生产和开发上进行部署。我想在部署时选择,是开发还是生产,一些方法的逻辑应该改变,这取决于部署类型。是否有任何想法,如何完成以及解决此问题的一些示例。例子:我有代码get'/api/test'doreturn"Itisdev"end但是在部署到生产环境之后我想在运行/api/test之后看到ItisPROD如何实现? 最佳答案 根据SinatraDocumentation:EnvironmentscanbesetthroughtheRACK_ENVenvironm
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
当我使用has_one时,它工作得很好,但在has_many上却不行。在这里您可以看到object_id不同,因为它运行了另一个SQL来再次获取它。ruby-1.9.2-p290:001>e=Employee.create(name:'rafael',active:false)ruby-1.9.2-p290:002>b=Badge.create(number:1,employee:e)ruby-1.9.2-p290:003>a=Address.create(street:"123MarketSt",city:"SanDiego",employee:e)ruby-1.9.2-p290
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
我正在使用带有Rails的Devise,我想添加一个方法“getAllComments”,所以我这样写:classUser在我的Controller中:defdashboard@user=current_user@comments=@user.getAllComments();end当我访问我的url时,我得到了undefinedmethod`getAllComments'for#我做错了什么?谢谢 最佳答案 因为getAllComments是一个类方法,而您正试图将其作为实例方法访问。您要么需要访问它:User.getAllCom
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上
我正在使用Rails3.2.3和Ruby1.9.3p0。我发现我经常需要确定某个字符串是否出现在选项列表中。看来我可以使用Ruby数组.includemethod:或正则表达式equals-tildematchshorthand用竖线分隔选项:就性能而言,一个比另一个好吗?还有更好的方法吗? 最佳答案 总结:Array#include?包含String元素,在接受和拒绝输入时均胜出,对于您的示例只有三个可接受的值。对于要检查的更大的集合,看起来Set#include?和String元素可能会获胜。如何测试我们应该根据经验对此进行测试
Ruby初学者努力简单地将这个@@people散列的值打印到控制台classPerson#haveafirst_nameandlast_nameattributewithpublicaccessorsattr_accessor:first_nameattr_accessor:last_name#haveaclassattributecalled`people`thatholdsanarrayofobjects@@people=[]#havean`initialize`methodtoinitializeeachinstancedefinitialize(first_name,last_