I have a table view and and tapping on any cell there is a detail view, my app get crashed when returning from detail to table list view, after going in detail view more than once.
#0 0x32d98f1c in objc_msgSend ()
#1 0x358da150 in _UIView ()
#2 0x358da040 in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] ()
#3 0x358da080 in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] ()
#4 0x358da080 in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] ()
#5 0x358d9f38 in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:] ()
#6 0x358f81dc in -[UIView(Hierarchy) removeFromSuperview] ()
#7 0x359af870 in -[UIScrollView removeFromSuperview] ()
#8 0x35900180 in -[UIView dealloc] ()
#9 0x374ffd7a in -[NSObject(NSObject) release] ()
#10 0x358f8230 in -[UIView(Hierarchy) removeFromSuperview] ()
#11 0x35900180 in -[UIView dealloc] ()
#12 0x359afffc in -[UIScrollView dealloc] ()
#13 0x374ffd7a in -[NSObject(NSObject) release] ()
#14 0x3516f7f4 in __delayedPerformCleanup ()
#15 0x3754d526 in CFRunLoopTimerInvalidate ()
#16 0x375522ac in __CFRunLoopDoTimer ()
#17 0x37521a90 in __CFRunLoopRun ()
#18 0x3752150a in CFRunLoopRunSpecific ()
#19 0x37521418 in CFRunLoopRunInMode ()
#20 0x33e76d24 in GSEventRunModal ()
#21 0x3591d57c in -[UIApplication _run] ()
#22 0x3591a558 in UIApplicationMain ()
How can i track the main reason behind this crash.
Thanks for any help.
I think in detailView dealloc method you are releasing an object which
is already release. it may be one of the reason to crash the app
Could it possible, that you reuse the DetailViewController Variable and only change the Data ?
Because i think that's a retain/release problem.
I suggest you rerun with zombies enabled. That should help you to pin point the problem which is most likely to be a pointer to a released object.
Related
I have a UIView that is a subview of UIScrollView.
I've done this to set the content size in viewDidLoad (useful snippet I found on this site):
CGFloat scrollViewHeight = 0.0f;
for (UIView* view in self.scrollView.subviews)
{
scrollViewHeight += view.frame.size.height;
}
[self.scrollView setContentSize:(CGSizeMake(320, scrollViewHeight))];
Using NSLogs I've determined the content size height is greater than the height of the scroll view. But, it still won't scroll. (I'm only interested in vertical scrolling.)
Scrolling is enabled in IB, so what am I missing?
This also happened to me - seems like when view is loaded from nib file some resizing happens after viewDidLoad and even after viewWillAppear.
The call stack shows it is resizeWithOldSuperviewSize who is doing that
#0 0x0000f040 in -[ScrollView setContentSize:] at .../ScrollView.m:49
#1 0x00092863 in -[UIScrollView _resizeWithOldSuperviewSize:] ()
#2 0x0007357a in -[UIView(Geometry) resizeWithOldSuperviewSize:] ()
#3 0x00072178 in __46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke_0 ()
#4 0x01ccb5a7 in __NSArrayChunkIterate ()
#5 0x01ca303f in __NSArrayEnumerate ()
#6 0x01ca2a16 in -[NSArray enumerateObjectsWithOptions:usingBlock:] ()
#7 0x0007210f in -[UIView(Geometry) resizeSubviewsWithOldSize:] ()
#8 0x0056d14c in -[UIView(AdditionalLayoutSupport) _is_layout] ()
#9 0x00076dfe in -[UIView(Hierarchy) layoutSubviews] ()
#10 0x0007e92d in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#11 0x010fa6b0 in -[NSObject performSelector:withObject:] ()
#12 0x022a5fc0 in -[CALayer layoutSublayers] ()
#13 0x0229a33c in CA::Layer::layout_if_needed(CA::Transaction*) ()
#14 0x022a5eaf in -[CALayer layoutIfNeeded] ()
#15 0x0011d8cd in -[UIViewController window:setupWithInterfaceOrientation:] ()
#16 0x000661a6 in -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] ()
#17 0x00064cbf in -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] ()
#18 0x00064bd9 in -[UIWindow _setRotatableViewOrientation:duration:force:] ()
#19 0x00063e34 in __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke_0 ()
#20 0x00063c6e in -[UIWindow _updateToInterfaceOrientation:duration:force:] ()
#21 0x00064a29 in -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] ()
#22 0x00067922 in -[UIWindow setDelegate:] ()
#23 0x00111fec in -[UIViewController _tryBecomeRootViewControllerInWindow:] ()
#24 0x0005ebc4 in -[UIWindow addRootViewControllerViewIfPossible] ()
#25 0x0005edbf in -[UIWindow _setHidden:forced:] ()
#26 0x0005ef55 in -[UIWindow _orderFrontWithoutMakingKey] ()
#27 0x00067f67 in -[UIWindow makeKeyAndVisible] ()
#28 0x0000379a in -[AppDelegate application:didFinishLaunchingWithOptions:] at .../AppDelegate.m:24
I didn't find a proper solution yet except setting contentSize later by calling performSelector:withObject:afterDelay
-(void)viewDidLoad
{
[self performSelector:#selector(adjustScrollViewContentSize) withObject:nil afterDelay:0.1];
}
-(void)adjustScrollViewContentSize
{
_scrollView.contentSize = CGSizeMake(4000, 4000);
}
is userInteractionEnabled property equal to TRUE? Perhaps you have a subview over your scrollview that is stealing the touches?
I agree with Sepehr. Something else must be stealing your touches. You can test this buy adding UIScollViewDelegate to your class and add one of the event call back methods below. If when you touch your scroll view they dont get called then you know Sepehr is correct.
(void)scrollViewDidScroll:(UIScrollView *)scrollView
(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
The issue comes from auto layout setting the contentSize based on constraints. Since my view was complex and auto layout was not up to the task I solved it by overriding setContentView: and ignoring auto layouts zero height setContentSize: message.
#interface MyView : UIScrollView {}
#end
#implementation MyView
- (void)setContentSize:(CGSize)aSize {
if (aSize.height > 0)
[super setContentSize:aSize];
}
#end
As an alternative to the use of performSelector:withObject:afterDelay suggested by ddenis, you could call setContentSize in viewDidLayoutSubviews:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
//do stuff here to calculate the content width and height
// ...
//then set the content size accordingly
[self.scrollView setContentSize:(CGSizeMake(contentWidth, contentHeight))];
}
I seem to be getting a crash right after doing [[CCDirector sharedDirector] popScene]. I am not really sure why. Any clues would help, thanks!
Crashlog:
#0 0x99e5ef84 in objc_msgSend ()
#1 0x302d543a in __NSFastEnumerationMutationHandler ()
#2 0x00046b46 in -[CCScheduler tick:] (self=0x1919ac0, _cmd=0x7b682, dt=0.0333320014) at /Users/Sup3rpanda/Dev/My Projects/Puzzle/libs/cocos2d/CCScheduler.m:211
#3 0x0001fb52 in -[CCDirector mainLoop] (self=0xf10a30, _cmd=0x76272) at /Users/Sup3rpanda/Dev/My Projects/Puzzle/libs/cocos2d/CCDirector.m:208
#4 0x305355cd in __NSFireTimer ()
#5 0x302454a0 in CFRunLoopRunSpecific ()
#6 0x30244628 in CFRunLoopRunInMode ()
#7 0x32044c31 in GSEventRunModal ()
#8 0x32044cf6 in GSEventRun ()
#9 0x309021ee in UIApplicationMain ()
#10 0x00002e94 in main (argc=1, argv=0xbfffef60) at /Users/Sup3rpanda/Dev/My Projects/Puzzle/main.m:13
Scheduled timer:
tGridTimer = [[CCTimer alloc] initWithTarget: self selector: #selector(gridSlideUpForced2:) interval: sGridSpeed];
[[CCScheduler sharedScheduler] scheduleTimer:tGridTimer];
Bit of CoCos 2d code that appears to be related to crashing:
-(void) tick: (ccTime) dt
{
if( timeScale_ != 1.0f )
dt *= timeScale_;
for( id k in methodsToRemove )
[scheduledMethods removeObject:k];
[methodsToRemove removeAllObjects];
for( id k in methodsToAdd )
[scheduledMethods addObject:k];
[methodsToAdd removeAllObjects];
for( CCTimer *t in scheduledMethods )
impMethod(t, fireSelector, dt);
[[CCScheduler sharedScheduler] scheduleTimer:tGridTimer];
Are you cleaning up your timers in onExit or dealloc in your scene class? Could be the scene still thinks some of the schedulers are still running
I'm coding a game for iphone in c++ and 100% opengl.
I need to add gamecenter to it so to show the UIViews I had to do something hackish.
void sb_socialShowAchievementsView(){
SocialDelegate* del = [[[SocialDelegate alloc] init] autorelease];
GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init];
if (achievements != nil) {
achievements.achievementDelegate = del;
HelperViewController* hvc = [[[HelperViewController alloc] init] autorelease];
[globalGLView addSubview:hvc.view];
[hvc presentModalViewController: achievements animated: YES];
}
[achievements release];
}
SocialDelegate implements protocols GKAchievementViewControllerDelegate and GKLeaderboardViewControllerDelegate.
globalGLView is my EAGLView instance.
and HelperViewController is just a UIViewController subclass.
The problem is when I call sb_socialShowAchievementsView() the app receives a SIGABRT with the following call stack and message:
*** Assertion failure in -[UIButtonLabel setTextColor:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UILabel.m:312
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: color'
#0 0x98ece156 in __kill
#1 0x98ece148 in kill$UNIX2003
#2 0x98f60899 in raise
#3 0x98f769b8 in abort
#4 0x961a2fda in __gnu_cxx::__verbose_terminate_handler
#5 0x03022333 in _objc_terminate
#6 0x961a117a in __cxxabiv1::__terminate
#7 0x961a11ba in std::terminate
#8 0x961a12b8 in __cxa_throw
#9 0x03022481 in objc_exception_throw
#10 0x02e8b238 in +[NSException raise:format:arguments:]
#11 0x022c6e37 in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
#12 0x0052260f in -[UILabel setTextColor:]
#13 0x005ec3d3 in -[UIButton layoutSubviews]
#14 0x002a0481 in -[CALayer layoutSublayers]
#15 0x002a01b1 in CALayerLayoutIfNeeded
#16 0x004bd976 in __-[UINavigationController _positionNavigationBarHidden:edge:]_block_invoke_1
#17 0x0043698f in +[UIView(Animation) _performWithoutAnimation:]
#18 0x004c1e26 in -[UINavigationController _positionNavigationBarHidden:edge:]
#19 0x004bd9ae in -[UINavigationController _positionNavigationBarHidden:]
#20 0x004bc0c3 in -[UINavigationController _updateBarsForCurrentInterfaceOrientation]
#21 0x004b99b1 in -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
#22 0x004c0bfd in -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:]
#23 0x0044217f in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#24 0x00440d94 in -[UIView(Hierarchy) _postMovedFromSuperview:]
#25 0x00439c30 in -[UIView(Internal) _addSubview:positioned:relativeTo:]
#26 0x00437f83 in -[UIView(Hierarchy) addSubview:]
#27 0x0049355b in -[UITransitionView transition:fromView:toView:]
#28 0x006a3a16 in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]
#29 0x004b710d in -[UIViewController presentModalViewController:withTransition:]
#30 0x0007ee96 in sb_socialShowAchievementsView at social-bindings-iphone.mm:184
I just can't get what am I doing wrong...
I encountered the exact same problem. I have a class that manages all the game center stuff which I wrote a couple of months ago, and it worked fine. I tried to import it to a new project, and called the standard methods to present the GKAchievementViewController, then it crashed with the same SIGABRT as you had. Then I tried authenticating the player first (which I would normally do before calling the achievements controller), and the problem went away. I guess it's a bug in the GameKit framework. I couldn't file a bug report because bug reporter obviously has it's own bugs :)
i get this error and EXC_BAD_ACESS when i run my maps application... any idea
#0 0x3510741c in objc_msgSend ()
#1 0x30a69364 in -[CLLocationManager onClientEventLocation:] ()
#2 0x30a66960 in -[CLLocationManager onClientEvent:supportInfo:] ()
#3 0x30a66b28 in OnClientEvent ()
#4 0x30a5f860 in CLClientInvokeCallback ()
#5 0x30a633e4 in CLClientHandleDaemonData ()
#6 0x357a902c in __CFMessagePortPerform ()
#7 0x3577be46 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#8 0x3577be04 in __CFRunLoopDoSource1 ()
#9 0x3576e0a4 in __CFRunLoopRun ()
#10 0x3576dd7a in CFRunLoopRunSpecific ()
#11 0x3576dc88 in CFRunLoopRunInMode ()
#12 0x336ace8c in GSEventRunModal ()
#13 0x318f0f94 in -[UIApplication _run] ()
#14 0x318ee4d4 in UIApplicationMain ()
#15 0x0000281c in main (argc=1, argv=0x2ffff5e0) at /Users/abcd/Desktop/wataproject/main.m:14
http://brainwashinc.wordpress.com/2010/01/05/mapkit-crash-getting-user-location/
This helped me solve this issue
#vivianaranha's approach might solve the issue but I believe (after encountering this myself) that you are doing something else bad.
Specifically, in my case I had set mapView.showsUserLocation = YES so under the hood mapView was wiring itself up to the CLLocationManager. The solution was to ensure that I called mapView.showsUserLocation = NO in viewWillDisappear.
Also I discovered that you must have mapView.userTrackingMode set to what you require before you make the call to mapView.showsUserLocation = YES. Putting it all together you end up with something like this:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.mapView.userTrackingMode = MKUserTrackingModeFollow;
self.mapView.showsUserLocation = YES;
self.mapView.delegate = self;
}
- (void)viewWillDisappear:(BOOL)animated {
self.mapView.userTrackingMode = MKUserTrackingModeNone;
self.mapView.showsUserLocation = NO;
self.mapView.delegate = nil;
[super viewWillDisappear:animated];
}
I have discovered that when my program starts, in one of my viewcontrollers the order of calling is viewDidAppear, viewWillAppear, viewDidAppear.
I was not expecting the first viewDidAppear to be called. What could be causing this and how do I fix it? ATM I have a flag in viewDiDAppear to check if viewWillAppear was called, but it's a hack.
The stacktrace (which is identical in bot calls to viewDidAppear)is:
#0 0x0000509e in -[MainView viewDidAppear:] at MainView.m:497
#1 0x3097e96e in -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
#2 0x30af3abe in -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:]
#3 0x30af4930 in -[UINavigationTransitionView _navigationTransitionDidStop]
#4 0x3091af0d in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
#5 0x3091ba9e in +[UIViewAnimationState popAnimationState]
#6 0x30af46fd in -[UINavigationTransitionView transition:fromView:toView:]
#7 0x30af3b01 in -[UINavigationTransitionView transition:toView:]
#8 0x30979f09 in -[UINavigationController _startDeferredTransitionIfNeeded]
#9 0x30a97d9c in -[UILayoutContainerView layoutSubviews]
#10 0x0040bd94 in -[CALayer layoutSublayers]
#11 0x0040bb55 in CALayerLayoutIfNeeded
#12 0x0040b3ae in CA::Context::commit_transaction
#13 0x0040b022 in CA::Transaction::commit
#14 0x308f942a in -[UIApplication _reportAppLaunchFinished]
#15 0x308fef33 in -[UIApplication handleEvent:withNewEvent:]
#16 0x308fad82 in -[UIApplication sendEvent:]
#17 0x309013e1 in _UIApplicationHandleEvent
#18 0x32046375 in PurpleEventCallback
#19 0x30245560 in CFRunLoopRunSpecific
#20 0x30244628 in CFRunLoopRunInMode
#21 0x308f930d in -[UIApplication _run]
#22 0x309021ee in UIApplicationMain
#23 0x00001e82 in main at main.m:14
I just ran into a very similar problem.
In my case, that was because of a bug from the ECSlidingViewController (https://github.com/edgecase/ECSlidingViewController).
I just updated the code from github, solved the problem.
Using a ECSlidingViewController, on top of the uikit navigationController, made the child's viewDidAppear called twice.
Put a break point in viewDidAppear, then inspect the call stack in the debugger. It will tell you what is calling the method.
When viewDidAppear is called, can you cancel another viewDidAppear in the event queue by following method ? Sometimes I use this to avoid some methods being called twice or more.
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:#selector(viewDidAppear) object:nil];
It's very likely that you want the behavior of viewDidLoad rather than viewDidAppear - viewDidAppear can be called multiple times by your ViewController when you're not expecting it to.