Created
March 30, 2010 17:58
-
-
Save NYiPhoneDeveloper/349364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <UIKit/UIKit.h> | |
| #import <AudioToolbox/AudioToolbox.h> | |
| // The delegates are something that we shall use in order to get more usefulness out of the | |
| // Application -It is given, and free funcitonality. | |
| @interface AttentionViewController : UIViewController <UIAlertViewDelegate, UIActionSheetDelegate> | |
| { | |
| IBOutlet UILabel *statusText; | |
| } | |
| @property (nonatomic, retain) IBOutlet UILabel *statusText; | |
| -(IBAction) doAlert: (id) sender; | |
| -(IBAction) doActionSheet: (id) sender; | |
| -(IBAction) doSound: (id) sender; | |
| -(IBAction) doAlertSound: (id) sender; | |
| -(IBAction) doVibration: (id) sender; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "AttentionViewController.h" | |
| @implementation AttentionViewController | |
| @synthesize statusText; | |
| -(IBAction) doAlert: (id) sender | |
| { | |
| UIAlertView *myAlert; | |
| myAlert = [[UIAlertView alloc] initWithTitle:@"my Alert" message: @"This is a message" delegate: self cancelButtonTitle: @"OK" otherButtonTitles: @"One", @"Two", nil]; | |
| [myAlert show]; | |
| [myAlert release]; | |
| } | |
| -(void) alertView: (UIAlertView *) alertView clickedButtonAtIndex: (NSInteger) buttonIndex | |
| { | |
| // Alert view is the parameter | |
| // buttonIndex is the parameter as well | |
| NSString *buttonTitle = [alertView buttonTitleAtIndex: buttonIndex]; | |
| if ([buttonTitle isEqualToString: @"One"]) | |
| { | |
| [statusText setText: [NSString stringWithFormat: @"You clicked %@", [alertView buttonTitleAtIndex: buttonIndex]]]; | |
| } | |
| else if ([buttonTitle isEqualToString: @"Two"]) | |
| { | |
| [statusText setText: [NSString stringWithFormat: @"You clicked %@", [alertView buttonTitleAtIndex: buttonIndex]]]; | |
| } | |
| else | |
| { | |
| statusText.text = @"Unknown"; | |
| } | |
| } | |
| -(IBAction) doActionSheet: (id) sender | |
| { | |
| UIActionSheet *myAction; | |
| myAction = [[UIActionSheet alloc] initWithTitle: @"Attention" delegate: self cancelButtonTitle: @"Cancel" destructiveButtonTitle: @"Destroy" otherButtonTitles: @"Negotiate", @"Compromise", @"Take action", @"Do Something", @"Code", @"Dont code", @"Sit still", nil]; | |
| [myAction showInView: self.view]; | |
| } | |
| -(void) actionSheet: (UIActionSheet *) actionSheet clickedButtonAtIndex: (NSInteger) buttonIndex | |
| { | |
| NSString *buttonTitle = [actionSheet buttonTitleAtIndex: buttonIndex]; | |
| if ([buttonTitle isEqualToString: @"Negotiate"]) | |
| { | |
| [statusText setText: [NSString stringWithFormat: @"Clicked %@", [actionSheet buttonTitleAtIndex: buttonIndex]]]; | |
| } | |
| else if ([buttonTitle isEqualToString: @"Compromise"]) | |
| { | |
| [statusText setText: [NSString stringWithFormat: @"Clicked %@", [actionSheet buttonTitleAtIndex: buttonIndex]]]; | |
| } | |
| else | |
| { | |
| [statusText setText: [NSString stringWithFormat: @"unknown"]]; | |
| } | |
| } | |
| -(IBAction) doSound: (id) sender | |
| { | |
| SystemSoundID soundID; | |
| NSString *soundFile = [[NSBundle mainBundle] pathForResource: @"soundeffect" ofType: @"wav"]; | |
| AudioServicesCreateSystemSoundID((CFURLRef) [NSURL fileURLWithPath:soundFile], &soundID); | |
| AudioServicesPlayAlertSound(soundID); | |
| } | |
| -(IBAction) doAlertSound: (id) sender | |
| { | |
| // System sounds are something that I need to learn more about | |
| // Also the methods of the framework is something that I need to learn more about. | |
| SystemSoundID soundID; | |
| NSString *soundFile = [[NSBundle mainBundle] pathForResource: @"alertsound" ofType: @"wav"]; | |
| AudioServicesCreateSystemSoundID((CFURLRef) [NSURL fileURLWithPath: soundFile], &soundID); | |
| AudioServicesPlayAlertSound(soundID); | |
| } | |
| -(IBAction) doVibration: (id) sender | |
| { | |
| AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); | |
| } | |
| /* | |
| // The designated initializer. Override to perform setup that is required before the view is loaded. | |
| - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { | |
| if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { | |
| // Custom initialization | |
| } | |
| return self; | |
| } | |
| */ | |
| /* | |
| // Implement loadView to create a view hierarchy programmatically, without using a nib. | |
| - (void)loadView { | |
| } | |
| */ | |
| /* | |
| // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. | |
| - (void)viewDidLoad { | |
| [super viewDidLoad]; | |
| } | |
| */ | |
| /* | |
| // Override to allow orientations other than the default portrait orientation. | |
| - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | |
| // Return YES for supported orientations | |
| return (interfaceOrientation == UIInterfaceOrientationPortrait); | |
| } | |
| */ | |
| - (void)didReceiveMemoryWarning { | |
| // Releases the view if it doesn't have a superview. | |
| [super didReceiveMemoryWarning]; | |
| // Release any cached data, images, etc that aren't in use. | |
| } | |
| - (void)viewDidUnload { | |
| // Release any retained subviews of the main view. | |
| // e.g. self.myOutlet = nil; | |
| } | |
| - (void)dealloc | |
| { | |
| [statusText release]; | |
| [super dealloc]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment