Rawand Ahmad Rawand Ahmad - 1 year ago 71
Objective-C Question

objective-c Pop-up window restrict access

i want a pop-up that would shown one time user opens app and, on the pop-up user have to enter their proper Activation Code to remove the pop-up or get in

Answer Source

You can either use an UIAlertController to do that as Sambit said or create an UIViewController with a UITextField and a UIButton.

Using the UIAlertController you can either present it from the AppDelegate didFinishLaunchingWithOptions method or from your initial UIViewController viewWillAppear method. I would use the second method but that is my personal preference.

Indiferent of the place you chose to do it you will have to create the UIAlertController, add the UITextField to it and a UIAlertAction. On the action method you check the activation code and if valid you proceed to the normal flow of the app, if not you display the UIAlertController again.

Using a UIViewController you will check the user input the same way you did with the UIAlertController and segue to a different screen if the code is valid.

To not display the verification screen/alert you can have a property stored on NSUserDefaults and check if it is set when the app launches.