Sauw Ming | bf16644 | 2010-03-30 12:33:52 +0000 | [diff] [blame^] | 1 | // |
| 2 | // FirstViewController.m |
| 3 | // ipjsua |
| 4 | // |
| 5 | // Created by Liong Sauw Ming on 3/23/10. |
| 6 | // Copyright Teluu Inc. (http://www.teluu.com) 2010. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | #import "FirstViewController.h" |
| 10 | #import "ipjsuaAppDelegate.h" |
| 11 | |
| 12 | |
| 13 | @implementation FirstViewController |
| 14 | @synthesize textField; |
| 15 | @synthesize textView; |
| 16 | @synthesize button1; |
| 17 | @synthesize text; |
| 18 | @synthesize hasInput; |
| 19 | |
| 20 | - (BOOL)textFieldShouldReturn:(UITextField *)theTextField { |
| 21 | // When the user presses return, take focus away from the text field so that the keyboard is dismissed. |
| 22 | if (theTextField == textField) { |
| 23 | [self.textField resignFirstResponder]; |
| 24 | self.hasInput = true; |
| 25 | self.text = [textField.text stringByAppendingString:@"\n"]; |
| 26 | textField.text = @""; |
| 27 | } |
| 28 | return YES; |
| 29 | } |
| 30 | |
| 31 | |
| 32 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event |
| 33 | { |
| 34 | // Dismiss the keyboard when the view outside the text field is touched. |
| 35 | [textField resignFirstResponder]; |
| 36 | [super touchesBegan:touches withEvent:event]; |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | // The designated initializer. Override to perform setup that is required before the view is loaded. |
| 41 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { |
| 42 | if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { |
| 43 | // Custom initialization |
| 44 | } |
| 45 | return self; |
| 46 | } |
| 47 | */ |
| 48 | |
| 49 | /* |
| 50 | // Implement loadView to create a view hierarchy programmatically, without using a nib. |
| 51 | - (void)loadView { |
| 52 | } |
| 53 | */ |
| 54 | |
| 55 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. |
| 56 | - (void)viewDidLoad { |
| 57 | [super viewDidLoad]; |
| 58 | |
| 59 | ipjsuaAppDelegate *appd = (ipjsuaAppDelegate *)[[UIApplication sharedApplication] delegate]; |
| 60 | appd.mainView = self; |
| 61 | textField.delegate = self; |
| 62 | [self.textView setFont:[UIFont fontWithName:@"Courier New" size:8.9]]; |
| 63 | [self.textField setEnabled: false]; |
| 64 | [button1 addTarget:self action:@selector(button1Pressed:) forControlEvents:(UIControlEvents)UIControlEventTouchDown]; |
| 65 | } |
| 66 | |
| 67 | - (void)button1Pressed:(id)sender { |
| 68 | /* Clear the text view */ |
| 69 | self.textView.text = @""; |
| 70 | } |
| 71 | |
| 72 | // Override to allow orientations other than the default portrait orientation. |
| 73 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
| 74 | // Return YES for supported orientations |
| 75 | return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
| 76 | } |
| 77 | |
| 78 | - (void)didReceiveMemoryWarning { |
| 79 | // Releases the view if it doesn't have a superview. |
| 80 | [super didReceiveMemoryWarning]; |
| 81 | |
| 82 | // Release any cached data, images, etc that aren't in use. |
| 83 | } |
| 84 | |
| 85 | - (void)viewDidUnload { |
| 86 | // Release any retained subviews of the main view. |
| 87 | // e.g. self.myOutlet = nil; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | - (void)dealloc { |
| 92 | [super dealloc]; |
| 93 | } |
| 94 | |
| 95 | @end |