iPad App crash in second run

Discussion in 'iOS Programming' started by Poy77, Jan 16, 2011.

  1. macrumors newbie

    Joined:
    Sep 5, 2010
    #1
    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:mad:" ...

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

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    So you looked them up in the documentation and read what it had to say right?
     
  3. Poy77, Jan 16, 2011
    Last edited by a moderator: Jan 17, 2011

    thread starter macrumors newbie

    Joined:
    Sep 5, 2010
    #3
    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:
    Code:
    - (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
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    So most likely currentImage is pointing at a released object or similar.
     
  5. Poy77, Jan 16, 2011
    Last edited by a moderator: Jan 17, 2011

    thread starter macrumors newbie

    Joined:
    Sep 5, 2010
    #5
    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.
     
  6. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
  7. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    It's not a solution at all. It avoids solving the problem.
     
  8. macrumors newbie

    Joined:
    Jan 18, 2011
    #8
    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.
     

Share This Page