100 likes | 193 Views
iOS Programming (TI 427). Alert ActionSheet. Lesson 5: Alert, ActionSheet. 1. Create a new Project 2. Select “ Single View Application” template and named it “ BAASheet ”. Lesson 5: Alert, ActionSheet. 3. Try clicking MainStoryBoard.storyboard to see the canvas below.
E N D
iOS Programming(TI 427) Alert ActionSheet
Lesson 5: Alert, ActionSheet 1. Create a new Project 2. Select “Single View Application” template and named it “BAASheet”
Lesson 5: Alert, ActionSheet 3. Try clicking MainStoryBoard.storyboard to see the canvas below
Lesson 5: Alert, ActionSheet 4. Click on the “Hide or Show Utilities” button on the top right in View to see a library of objects.
Lesson 5: Alert, ActionSheet Note: You can use Command + D to duplicate the button. 5. Drag 2 Buttons to the View. Name it “Show Alert” and “Show Action Sheet”
Lesson 5: Alert, ActionSheet 6. Now Create 2 new procedures one to show an Alert Box and another to show an Action Sheet. Click on the “Show the Assistant Editor” button, the Middle button in the Editor Buttons on the top right. This will show the Code View along side the Canvas View.
Lesson 5: Alert, ActionSheet Now drag the each button to create a procedure. You show be familiar with the process.
Lesson 5: Alert, ActionSheet 7. GotoViewController.m and add the following code to each procedure - (IBAction)ShowAlertbox:(id)sender { UIAlertView *myAlert = [[UIAlertViewalloc] initWithTitle:@"This my Alertbox"message: @"Great Success!"delegate:nilcancelButtonTitle:@"Ok"otherButtonTitles:nil]; [myAlertshow]; } - (IBAction)ShowActionSheet:(id)sender { UIActionSheet *actionSheet = [[UIActionSheetalloc] initWithTitle:@"Confirm to Exit?" delegate:nil cancelButtonTitle:@"No!" destructiveButtonTitle:@"Yes" otherButtonTitles:nil]; [actionSheetshowInView:self.view]; }
Lesson 5: Alert, ActionSheet 8. Make sure that you bind those buttons to their respective Procedures in UIView Controller at the Dock
Lesson 5: Alert, ActionSheet To have the ActionSheet Buttons to perform an action, Please read the remarks in the coding. 9. Run and test both buttons.