Xcode pop up?

Discussion in 'iOS Programming' started by njharris97, Nov 1, 2013.

  1. njharris97 macrumors member

    Hi guys, I have created an App for a high school, and every so often we need a one time pop up to appear when they open the app with a button taking them to a page in the storyboard.

    Could anyone direct me on how I could do this, I am running the latest version of Xcode and am using StoryBoards.

  2. Duncan C, Nov 1, 2013
    Last edited: Nov 1, 2013

    Duncan C macrumors 6502a

    Duncan C

    Jan 21, 2008
    Northern Virginia
    In your app delegate, implement the applicationWillEnterForeground method. In that method, use arc4random_uniform to generate a random number from 0 to 99. Then, whatever percentage of the time that you want, and display a UIAlert with a "do it" button and a cancel button. Implement the alert delegate method, and when the user clicks the "do it" button, use the UIStoryboard method instantiateViewControllerWithIdentifier to create a view controller from your storyboard, and present it modally using presentViewController:animated:completion:

    int rand = arc4random_uniform(100);
    if (rand<10)
      //Create and display a UIAlertView

Share This Page