【发布时间】:2017-07-24 07:40:08
【问题描述】:
尽管它在模拟器上运行良好,但我的多视图应用程序在 iPhone 5 C 上崩溃(我的意思是“很好”,我的意思是没有内存泄漏、按钮移动到位时的流畅动画等)。该应用程序是用 Objective C 编写的,模拟器在 Xcode 8.3.3 下运行。手机运行 iOS 10.3.3。
当我按下从SyncViewController 切换到PlayViewController 的同步按钮时,即在从 VC1 成功切换到 VC2 到 VC3 后从 VC3 到 VC4 时,就会出现问题。每个ViewController 都有一个委托方法来响应从前一个ViewController. 中按下的按钮
崩溃始终在以下方法中发生,该方法在PlayView 中显示三件事:一个水平滚动的图形乐谱、一个带有每秒覆盖的时间显示的按钮和一个停止按钮。
- (UIView *)showScoreClockAndExit:(CGRect)panel highlight:(int)currentState seconds:(NSUInteger)clockCount {
if (!self.seconds)
{
[self.seconds removeFromSuperview];
self.seconds = [[ClockButton alloc] loadClockButton:(NSUInteger)clockCount];
[self addSubview:_seconds];
}
ClockButton *seconds = [[ClockButton alloc] loadClockButton:(NSUInteger)clockCount];
[self addSubview:seconds];
EscButton *escape = [[EscButton alloc] loadEscButton:(NSString *)@"stop"];
[self addSubview:escape];
GraphicScore *score = [[GraphicScore alloc] createGraphicScore:(CGRect)panel highlight:(int)currentState];
[self addSubview:score];
return self;
}
奇怪的是,之前由SyncViewController 加载的最后一个UIView 仍然冻结在设备本身上,即使PlayViewController 已经开始从SyncViewController, 接管,即PlayView 已加载,@987654333 @ 已设置,所选播放器的播放状态已启用,调试日志(下面)清楚地显示了
2017-07-24 15:25:24.950097+1000 SatGam2[3052:1712261] PlayView loaded (selectedFamily:1 selectedPlayerID:1)
2017-07-24 15:25:24.950923+1000 SatGam2[3052:1712261] TIME: 00:00
2017-07-24 15:25:24.951905+1000 SatGam2[3052:1712261] ENABLED (player 1: state 0)
(lldb)
根据我找到的 here 的有用线索,我输入:bt 并按下:Enter 以获取以下日志
SatGam2 was compiled with optimization - stepping may behave oddly; variables may not be available.
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xe15d25d2)
frame #0: 0x1b300694 libobjc.A.dylib`objc_retain + 4
frame #1: 0x21291d0a UIKit`-[UIView(Hierarchy) addSubview:] + 18
* frame #2: 0x000c2696 SatGam2`-[PlayView showScoreClockAndExit:highlight:seconds:](self=0x15e9ed70, _cmd=<unavailable>, panel=<unavailable>, currentState=<unavailable>, clockCount=<unavailable>) at PlayView.m:215 [opt]
frame #3: 0x000c246c SatGam2`-[PlayView initWithFrame:state:family:player:cue:seconds:](self=<unavailable>, _cmd=<unavailable>, frame=<unavailable>, currentState=<unavailable>, selectedFamily=<unavailable>, selectedPlayerID=<unavailable>, entryString=@"", clockCount=<unavailable>) at PlayView.m:149 [opt]
frame #4: 0x000cd0da SatGam2`-[PlayViewController nextState](self=0x168aae00, _cmd=<unavailable>) at PlayViewController.m:244 [opt]
frame #5: 0x000ccc40 SatGam2`-[PlayViewController viewDidLoad](self=0x168aae00, _cmd=<unavailable>) at PlayViewController.m:152 [opt]
frame #6: 0x2128b27e UIKit`-[UIViewController loadViewIfRequired] + 966
frame #7: 0x2128aea0 UIKit`-[UIViewController view] + 22
frame #8: 0x000c1266 SatGam2`-[MultiviewViewController displayView:](self=0x15d85710, _cmd=<unavailable>, intNewView=4) at MultiviewViewController.m:45 [opt]
frame #9: 0x000c2fb6 SatGam2`-[SyncViewController fromSyncButton:](self=<unavailable>, _cmd=<unavailable>, button=<unavailable>) at SyncViewController.m:65 [opt]
frame #10: 0x212bf784 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 76
frame #11: 0x212bf718 UIKit`-[UIControl sendAction:to:forEvent:] + 62
frame #12: 0x212a9d48 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 478
frame #13: 0x212bf054 UIKit`-[UIControl touchesEnded:withEvent:] + 604
frame #14: 0x212beb9e UIKit`-[UIWindow _sendTouchesForEvent:] + 2094
frame #15: 0x212b9ade UIKit`-[UIWindow sendEvent:] + 2798
frame #16: 0x2128b682 UIKit`-[UIApplication sendEvent:] + 308
frame #17: 0x21a1ede6 UIKit`__dispatchPreprocessedEventFromEventQueue + 2254
frame #18: 0x21a1978a UIKit`__handleEventQueue + 4186
frame #19: 0x21a19b6c UIKit`__handleHIDEventFetcherDrain + 144
frame #20: 0x1c01bfdc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
frame #21: 0x1c01bb04 CoreFoundation`__CFRunLoopDoSources0 + 424
frame #22: 0x1c019f50 CoreFoundation`__CFRunLoopRun + 1160
frame #23: 0x1bf6d1ae CoreFoundation`CFRunLoopRunSpecific + 470
frame #24: 0x1bf6cfd0 CoreFoundation`CFRunLoopRunInMode + 104
frame #25: 0x1d717b40 GraphicsServices`GSEventRunModal + 80
frame #26: 0x212eee12 UIKit`UIApplicationMain + 150
frame #27: 0x1b75a4ea libdyld.dylib`start + 2
(lldb)
我清除了之前在手机上测试过的所有应用。我还尝试了上个月备份的应用程序版本,以消除我开始使用deviceMotion 以来可能引入的任何问题。但问题依旧。
有人见过这样的吗?我会从哪里开始?例如比如我会在哪里设置断点?
【问题讨论】:
-
设置异常断点;在方法的开头设置代码断点
-[PlayView showScoreClockAndExit:highlight:seconds:]并从那里开始... -
模拟器和设备之间有很多不同之处。模拟器基本上是在 Mac 硬件上运行的 x86-64 版本的 iOS。你的 iPhone 5C 是 32 位的,等等......
-
谢谢,尼古拉斯。我试过了,得到 _cmd = (SEL) "showScoreClockAndExit:highlight:seconds:"
, seconds = (ClockButton *) nil, escape = (EscButton *) nil, score = (GraphicScore *) nil。但是即使没有进一步的步骤,当设备屏幕仍然显示旧的 UIViewController中的UIView时,我也不会期待其他任何东西 -
这些是接下来的步骤:
if (!self.seconds) {后跟[self addSubview:_seconds];(无限重复) -
根据您提供的输出,我的第一个检查将是零(显然,您不希望为零)。
标签: ios objective-c iphone xcode