我在仅在设备上发布的版本中发生了非常间歇性的崩溃。这是崩溃日志的相关部分:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000f
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x357c6fbc objc_msgSend + 16
1 CoreFoundation 0x33ff9020 CFRetain + 76
2 GraphicsServices 0x35c45af2 GSFontCreateWithName + 178
3 UIKit 0x3514264c UINewFont + 52
4 UIKit 0x351425fc +[UIFont systemFontOfSize:traits:] + 12
5 MyApp 0x0002bc68 -[STDrawer createButtonWithTitle:backgroundColor:] (STDrawer.mm:284)
6 MyApp 0x0002b8e0 -[STDrawer displayActionButtonsWithTitlesArray:] (STDrawer.mm:179)
7 MyApp 0x0002b7e0 -[STDrawer displayActionButtonsWithTitles:] (STDrawer.mm:146)
8 MyApp 0x0000fb72 -[STGameController playerToAct:] (STGameController.mm:940)
9 MyApp 0x00015b16 -[STGame playerToAct:] (STGame.mm:218)
10 MyApp 0x00018c0e -[STGameClient processMessage:arg:argLen:] (STGameClient.mm:461)
11 MyApp 0x00017520 -[STGameClient dataReceived:] (STGameClient.mm:150)
12 MyApp 0x0003a02c -[STLocalConnClient(STPrivate) dataReceivedFromServerCb:] (STLocalConnClient.mm:115)
13 Foundation 0x31b7593c __NSFireDelayedPerform + 408
14 CoreFoundation 0x34084a5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
15 CoreFoundation 0x340846c2 __CFRunLoopDoTimer + 358
16 CoreFoundation 0x34083298 __CFRunLoopRun + 1200
17 CoreFoundation 0x340064d6 CFRunLoopRunSpecific + 294
18 CoreFoundation 0x3400639e CFRunLoopRunInMode + 98
19 GraphicsServices 0x35c46fc6 GSEventRunModal + 150
20 UIKit 0x3514b73c UIApplicationMain + 1084
21 MyApp 0x000031c8 main (main.mm:113)
22 MyApp 0x00002e28 start + 32
这是缩短的代码:
-(UIButton*)createButtonWithTitle: (NSString*)title backgroundColor: (UIColor*)backgroundColor
{
...
UIButton* button = [[UIButton alloc] initWithFrame: CGRectZero];
button.titleLabel.font = [UIFont systemFontOfSize: (st::STUIDims::Self())->DrawerFontSize()];
button.titleLabel.adjustsFontSizeToFitWidth = YES;
[button setTitle: title forState: UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
...
return [button autorelease];
}
我已经看到至少 4 次崩溃来自 button.titleLabel.font 行和一次来自 button.titleLabel.adjustsFontSizeToFitWidth (后者因 -[ CALayer pointSize]: 无法识别的选择器发送到实例).
我认为这是一个内存问题,所以我在模拟器下使用 Valgrind 运行应用程序,包括发布和调试版本,但没有任何结果。它在 Apple 的库中找到了一堆东西,但在我的代码中什么也没有。并且崩溃在分配后立即发生。它怎么会腐败得这么快?
我不确定下一步该做什么。非常欢迎任何建议。
编辑:这是对 adjustsFontSizeToFitWidth 的放大:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x33a888bf __exceptionPreprocess + 163
1 libobjc.A.dylib 0x351a41e5 objc_exception_throw + 33
2 CoreFoundation 0x33a8bacb -[NSObject doesNotRecognizeSelector:] + 175
3 CoreFoundation 0x33a8a945 ___forwarding___ + 301
4 CoreFoundation 0x339e5680 _CF_forwarding_prep_0 + 48
5 UIKit 0x34b84107 -[UILabel setAdjustsFontSizeToFitWidth:] + 279
6 MyApp 0x0003b7e4 -[STDrawer createButtonWithTitle:backgroundColor:] (STDrawer.mm:288)
7 MyApp 0x0003b4a0 -[STDrawer displayActionButtonsWithTitlesArray:] (STDrawer.mm:184)
8 MyApp 0x0003b364 -[STDrawer displayActionButtonsWithTitles:] (STDrawer.mm:147)
9 MyApp 0x00014ba8 -[STGameController playerToAct:] (STGameController.mm:943)
10 MyApp 0x0001c0bc -[STGame playerToAct:] (STGame.mm:219)
11 MyApp 0x0001fa98 -[STGameClient processMessage:arg:argLen:] (STGameClient.mm:461)
12 MyApp 0x000213b4 -[STGameClient dataReceived:] (STGameClient.mm:151)
13 MyApp 0x00050c7c -[STLocalConnClient(STPrivate) dataReceivedFromServerCb:] (STLocalConnClient.mm:116)
14 Foundation 0x3154d943 __NSFireDelayedPerform + 415
15 CoreFoundation 0x33a5ca63 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15
16 CoreFoundation 0x33a5c6c9 __CFRunLoopDoTimer + 365
17 CoreFoundation 0x33a5b29f __CFRunLoopRun + 1207
18 CoreFoundation 0x339de4dd CFRunLoopRunSpecific + 301
19 CoreFoundation 0x339de3a5 CFRunLoopRunInMode + 105
20 GraphicsServices 0x3561efcd GSEventRunModal + 157
21 UIKit 0x34b23743 UIApplicationMain + 1091
22 MyApp 0x000031f8 main (main.mm:121)
23 MyApp 0x00002c90 start + 40
最佳答案
我遇到了同样的问题,结果是我不小心
[self.button setImage:iconImageName forState:UIControlStateNormal];
使用 NSString 而不是 UIImage 设置图像
关于iphone - 奇怪的 iOS 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9318377/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
当我在Rails控制台中按向上或向左箭头时,出现此错误:irb(main):001:0>/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rb-readline-0.4.2/lib/rbreadline.rb:4269:in`blockin_rl_dispatch_subseq':invalidbytesequenceinUTF-8(ArgumentError)我使用rvm来管理我的ruby安装。我正在使用=>ruby-2.0.0-p247[x86_64]我使用bundle来管理我的gem,并且我有rb-readline(0.4.2)(人们推荐的最少
这里有一个很好的答案解释了如何在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”结果的
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
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上
有没有人用ruby解决这个问题:假设我们有:a=8.1999999我们想将它四舍五入为2位小数,即8.20,然后乘以1,000,000得到8,200,000我们是这样做的;(a.round(2)*1000000).to_i但是我们得到的是8199999,为什么?奇怪的是,如果我们乘以1000、100000或10000000而不是1000000,我们会得到正确的结果。有人知道为什么吗?我们正在使用ruby1.9.2并尝试使用1.9.3。谢谢! 最佳答案 每当你在计算中得到时髦的数字时使用bigdecimalrequire'bi
defreverse(ary)result=[]forresult[0,0]inaryendresultendassert_equal["baz","bar","foo"],reverse(["foo","bar","baz"])这行得通,我想了解原因。有什么解释吗? 最佳答案 如果我使用each而不是for/in重写它,它看起来像这样:defreverse(ary)result=[]#forresult[0,0]inaryary.eachdo|item|result[0,0]=itemendresultendforainb基本上就
当我写下面的代码时:x=[1,2,3]x我得到这个输出:[1,2,3,[...]][1,2,3,[...]][1,2,3,[...]]我不应该只得到[1,2,3,[1,2,3]]吗?解释是什么? 最佳答案 这没什么奇怪的。数组的第四个元素就是数组本身,所以当你求第四个元素时,你得到的是数组,当你求第四个元素的第四个元素时,你得到的是数组,当你求第四个元素时,你得到的是数组。第四个元素的第四个元素的第四个元素的元素......你得到了数组。就这么简单。唯一有点不寻常的是Array#to_s检测到这样的递归,而不是进入无限循环,而是返回
以下测试中的第3个失败:specify{(0.6*2).shouldeql(1.2)}specify{(0.3*3).shouldeql(0.3*3)}specify{(0.3*3).shouldeql(0.9)}#thisonefails这是为什么呢?这是浮点问题还是ruby或rspec问题? 最佳答案 从rspec-2.1开始specify{(0.6*2).shouldbe_within(0.01).of(1.2)}在那之前:specify{(0.6*2).shouldbe_close(1.2,0.01)}