PDA

View Full Version : iPad App crash in second run




Poy77
Jan 16, 2011, 02:07 PM
I have started my app with 3.2 sw and tested it with iPod Touch 2nd gen. Now I added support to iPad. In both devices the current sw version is IOS4.2.
iPad crash in second run but iPod not. It seems that iPad load old view from memory even I have deallocated it. iPod starts always with the new view. I want that it starts always from the beginning.

I don't use UIViewController app, it is UIView:
aViewController = [[UIViewController alloc] initWithNibName:@" ...

If I now generate new template project, I can see that there is lot of new methods. I am not familiar with them.



robbieduncan
Jan 16, 2011, 02:18 PM
I am not familiar with them.

So you looked them up in the documentation and read what it had to say right?

Poy77
Jan 16, 2011, 03:13 PM
So you looked them up in the documentation and read what it had to say right?
Actually yes, but maybe not enough. Why I am asking here, I thought that it could be just a small thing, which I have missed.
I debugged that it chashed in one of the UIView classes:
- (void)drawRect:(CGRect)rect {
// Drawing code
[currentImage drawAtPoint:(CGPointMake(0.0, 0.0))];
}

Then in first run, following AppDelegate class methods are called:
i)applicationDidFinishLaunching
ii)applicationDidBecomeActive

And in second time:
i)applicationWillResignActive
ii)applicationDidEnterBackground
iii)applicationWillEnterForeground
iiii)applicationDidBecomeActive

robbieduncan
Jan 16, 2011, 03:15 PM
So most likely currentImage is pointing at a released object or similar.

Poy77
Jan 16, 2011, 03:27 PM
So most likely currentImage is pointing at a released object or similar.
And I don't have any need to save data during backround or support multitasking.

EDIT:

I solved the problem. I had to define non-backround support in plist file.

PhoneyDeveloper
Jan 17, 2011, 11:08 AM
That's a cheese ball solution.

robbieduncan
Jan 17, 2011, 01:40 PM
That's a cheese ball solution.

It's not a solution at all. It avoids solving the problem.

OpRisk
Jan 18, 2011, 09:36 PM
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5)

If you need to update a UIView, try using setNeedsDisplay; also, you can try using the
-(void)viewWillAppear.

I am not really clear from your post as to what exactly you are trying to do, but it seems that you're trying to "restart" your app from the beginning everytime it gets launched. Doing the above might a direction you might want to take.