我是导航控制器视图,带有工具栏,搜索栏和&实现代码如下。 在设备orienatation改变两次,我看到奇怪
*** -[UIImage isKindOfClass:]: message sent to deallocated instance 0x7a31c00
(lldb) bt
* thread #1: tid = 0x1f03, 0x93e06332 libsystem_kernel.dylib`__kill + 10, stop reason = signal SIGKILL
frame #0: 0x93e06332 libsystem_kernel.dylib`__kill + 10
frame #1: 0x93e05932 libsystem_kernel.dylib`kill$UNIX2003 + 32
frame #2: 0x01e10e03 CoreFoundation`___forwarding___ + 227
frame #3: 0x01e10cb2 CoreFoundation`_CF_forwarding_prep_0 + 50
frame #4: 0x00ae1a06 UIKit`-[UIImageView _setViewGeometry:forMetric:] + 295
frame #5: 0x00ae1c2d UIKit`-[UIImageView setFrame:] + 63
frame #6: 0x00a2b9f2 UIKit`-[UIView(Geometry) _resizeWithOldSuperviewSize:] + 838
frame #7: 0x00a2c08a UIKit`-[UIView(Geometry) resizeWithOldSuperviewSize:] + 72
frame #8: 0x00a2b3b5 UIKit`__46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke_0 + 73
frame #9: 0x01e41f1a CoreFoundation`__NSArrayChunkIterate + 362
frame #10: 0x01e0d635 CoreFoundation`__NSArrayEnumerate + 997
frame #11: 0x01e0d026 CoreFoundation`-[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
frame #12: 0x00a2b353 UIKit`-[UIView(Geometry) resizeSubviewsWithOldSize:] + 149
frame #13: 0x00a2a058 UIKit`-[UIView(Geometry) setFrame:] + 358
frame #14: 0x00abaf20 UIKit`-[UIViewControllerWrapperView setFrame:] + 193
frame #15: 0x00acfc13 UIKit`-[UINavigationController _layoutViewController:] + 335
frame #16: 0x00acf81c UIKit`-[UINavigationController _layoutTopViewController] + 155
frame #17: 0x00ad0899 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded] + 346
frame #18: 0x00ad09e1 UIKit`-[UINavigationController __viewWillLayoutSubviews] + 33
frame #19: 0x00bee5c2 UIKit`-[UILayoutContainerView layoutSubviews] + 222
frame #20: 0x00a34d21 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 145
frame #21: 0x01eabe42 CoreFoundation`-[NSObject performSelector:withObject:] + 66
frame #22: 0x0304e679 QuartzCore`-[CALayer layoutSublayers] + 266
frame #23: 0x03058579 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 231
frame #24: 0x0304e740 QuartzCore`-[CALayer layoutIfNeeded] + 184
frame #25: 0x00a2e938 UIKit`-[UIView(Hierarchy) layoutIfNeeded] + 42
frame #26: 0x00ac898a UIKit`-[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] + 565
frame #27: 0x00a21ef9 UIKit`-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 4712
frame #28: 0x00a20c8c UIKit`-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
frame #29: 0x00a20b97 UIKit`-[UIWindow _setRotatableViewOrientation:duration:force:] + 93
frame #30: 0x00a2017b UIKit`-[UIWindow _updateToInterfaceOrientation:duration:force:] + 228
frame #31: 0x00a202ac UIKit`-[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 162
frame #32: 0x00a20203 UIKit`-[UIWindow _updateInterfaceOrientationFromDeviceOrientationIfRotationEnabled:] + 82
frame #33: 0x00a20028 UIKit`-[UIWindow _handleDeviceOrientationChange:] + 121
frame #34: 0x013b8a29 Foundation`__57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 40
frame #35: 0x01e75855 CoreFoundation`___CFXNotificationPost_block_invoke_0 + 85
frame #36: 0x01e75778 CoreFoundation`_CFXNotificationPost + 1976
frame #37: 0x012fd19a Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 98
frame #38: 0x00bccdb1 UIKit`-[UIDevice setOrientation:animated:] + 220
frame #39: 0x00a042fd UIKit`-[UIApplication handleEvent:withNewEvent:] + 1405
frame #40: 0x00a04c38 UIKit`-[UIApplication sendEvent:] + 68
frame #41: 0x009f8634 UIKit`_UIApplicationHandleEvent + 8196
frame #42: 0x01cadef5 GraphicsServices`PurpleEventCallback + 1274
frame #43: 0x01e7e195 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #44: 0x01de2ff2 CoreFoundation`__CFRunLoopDoSource1 + 146
frame #45: 0x01de18da CoreFoundation`__CFRunLoopRun + 2218
frame #46: 0x01de0d84 CoreFoundation`CFRunLoopRunSpecific + 212
frame #47: 0x01de0c9b CoreFoundation`CFRunLoopRunInMode + 123
frame #48: 0x01cac7d8 GraphicsServices`GSEventRunModal + 190
frame #49: 0x01cac88a GraphicsServices`GSEventRun + 103
frame #50: 0x009f6626 UIKit`UIApplicationMain + 1163
我在委托中没有任何代码
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
shouldAutorotateToInterfaceOrientation支持所有方向 我可以找到崩溃的原因
答案 0 :(得分:0)
我在UItoolbar类上面创建了自定义工具栏,其中包含background.which导致方向更改崩溃
@interface CustomWhiteToolbar : UIToolbar {
}
@end
@implementation CustomWhiteToolbar
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
UIImage *img = [UIImage imageNamed: @"White_bordered_background.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
[img release];
self.tintColor = [UIColor clearColor];
}
@end
这导致方向更改崩溃。我将自定义工具栏类设置为我的xib内的工具栏。我无法找到原因导致崩溃