Modal UIAlertView

Discussion in 'iOS Development' started by Collateral, Nov 12, 2009.

  1. Collateral

    Collateral Active Member

    Joined:
    Sep 23, 2007
    Messages:
    1,974
    Likes Received:
    6
    Device:
    iPhone 3GS (Black)
    Is it possible to make a UIAlertView into a modal view so that workflow on my main program halts until it receives input from the user from the UIAlertView?

    Right now I am calling a UIAlertView, and then calling a method, however the method is being called before the UIAlertView is dismissed by the end user.

    They way I have it written, however, will force me to re-write all of my code if i have to write all of it into an alertView:clickedButtonAtIndex: method, so i am trying to avoid that.


    Any thoughts?



    EDIT: im looking at this but it doesnt look like its exactly what i want beacuse it seems to want a tap to get the attention of the alert view.

    [OBJC]@interface UIAlertView (Synthesize)
    (void)setRunsModal

    Please Register or Log in to view images

    BOOL)modal;
    @end
    [alert setRunsModal:YES];
    [alert show];[/OBJC]

    EDIT 2:
    I tried having it run a loop while alertView.hidden != YES, but that just stopped the alert from even showing up... the program just froze. :/
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    I think it is already model and it need alertView:clickedButtonAtIndex: to get input from it. How you know which index that users selected without that delegate?
  3. Collateral

    Collateral Active Member

    Joined:
    Sep 23, 2007
    Messages:
    1,974
    Likes Received:
    6
    Device:
    iPhone 3GS (Black)
    Saying that a view is "Modal" implies that it stops the main thread execution until the view is released. Therefore UIAlertView is not modal.

    I would still need that delegate to respond to what the user clicked, but i need to respond to that delegate before the main thread continues its code execution, thats why i need the view to be modal.
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Sorry, but UIAlertView is the archetypical modal view. I think your understanding of the adjective might be skewed. Example, the whole point of "modal view" is to NOT cause your main thread to stop and wait. Kind of the opposite from what you're expecting.

    However, to solve your problem, you may need to get into threading. Just perform selector on thread, (some other thread), want until done. Either that, or simply lock the thread after the alert is shown, and unlock it before it is dismissed. Alternatively think of a new UI design.

Share This Page