+ Reply
Results 1 to 6 of 6
  1. #1
    What's Jailbreak?
    Join Date
    Aug 2008
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Force Update/Refresh UI

    Hi,

    following problem:

    I want to show a "loading view" directly after app finishes launching - so I do addSubView at the beginning of applicationDidFinishLaunching.

    Next in applicationDidFinishLaunching I will load some sqlite dbs - this takes some time and during that the loading screen should be displayed...

    Afterwards in applicationDidFinishLaunching I call addSubView with my main view.

    What happens is: "loading view" will never show up but the screen will be black untill all loading is done and applicationDidFinishLaunching returns.

    >>> So what I am looking for is a way to force the UI to update and hence actually SHOW my "loading view" in mid-function of applicationDidFinishLaunching.

    Thanks for any input!

    greetz
    humbold

  2. #2
    Developer NetMage's Avatar
    Join Date
    Aug 2007
    Location
    Virginia
    Posts
    1,292
    Thanks
    71
    Thanked 210 Times in 168 Posts

    In principle your loading view should be the Default.png in your application directory.

    SpringBoard will display that image, than launch your application, which will execute applicationDidFinishLaunching. When that returns, your views will display over the Default.png, removing it from the display.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

  3. The Following User Says Thank You to NetMage For This Useful Post:

    humbold (08-24-2008)

  4. #3
    What's Jailbreak?
    Join Date
    Aug 2008
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thanks! that's interesting though a bit unsatisfying

    What if have to load something (or perform a longer task) when the application is already running? There has to be some way to force the UI to update BEFORE the main loop continues...

  5. #4
    Developer NetMage's Avatar
    Join Date
    Aug 2007
    Location
    Virginia
    Posts
    1,292
    Thanks
    71
    Thanked 210 Times in 168 Posts

    I think if you had a long task, you should spin off a thread and return to the event loop so your application remains responsive.

    In any case, the Cocoa documentation says this:

    If you need to force immediate drawing of a view, send the view one of the display... messages declared by both NSView and NSWindow. You can also lock focus on a view yourself, draw something, and then unlock focus. However, posting deferred drawing requests through the setNeedsDisplay: or setNeedsDisplayInRect: methods is the preferred approach because it is more efficient.

    The iPhone documentation does not have equivalent documented display... messages. There is an undocumented method, but it can't be used with SDK applications.
    It seems Apple has decided in the iPhone world of limited cycles, it is best to let the run loop handle all screen drawing, to minimize unnecessary drawing and clean up application flow.
    Last edited by NetMage; 08-25-2008 at 12:36 AM.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

  6. The Following User Says Thank You to NetMage For This Useful Post:

    humbold (08-25-2008)

  7. #5
    What's Jailbreak?
    Join Date
    Aug 2008
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Ah ok what is this undocumented function? since I am using undocumented apis anyway that would be the optimal solution for me then...

  8. #6
    Developer NetMage's Avatar
    Join Date
    Aug 2007
    Location
    Virginia
    Posts
    1,292
    Thanks
    71
    Thanked 210 Times in 168 Posts

    I would suggest trying calling setNeedsDisplay and then calling recursivelyForceDisplayIfNeeded on the UIWindow.

    I really suggest not doing it, though, and following the proper way - it may (will) annoy the user if pressing home does nothing for an extended period of time.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts