Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

njharris97

macrumors member
Original poster
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.

Thanks.
 
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.

Thanks.

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:

Code:
int rand = arc4random_uniform(100);
if (rand<10)
{
  //Create and display a UIAlertView
}
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.