Guest User

Untitled

a guest
May 22nd, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.91 KB | None | 0 0
  1. #import "EditClass.h"
  2. #import "testAppDelegate.h"
  3.  
  4. @interface EditClass (Private)
  5. - (void)createPicker;
  6. @end
  7.  
  8. @implementation EditClass
  9. @synthesize newClass, profName, className, mypicker, pickerArray, time, room, newViewMap;
  10.  
  11. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  12. if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  13. // Initialization code
  14. }
  15. return self;
  16. }
  17.  
  18. /*
  19. Implement loadView if you want to create a view hierarchy programmatically
  20. - (void)loadView {
  21. }
  22. */
  23.  
  24.  
  25. // If you need to do additional setup after loading the view, override viewDidLoad.
  26. - (void)viewDidLoad {
  27. [self.view setBackgroundColor:[UIColor blackColor]];
  28. UIBarButtonItem *saveButton = [[[UIBarButtonItem alloc]
  29. initWithTitle:NSLocalizedString(@"Save Changes", @"")
  30. style:UIBarButtonItemStyleBordered
  31. target:self
  32. action:@selector(saveAction:)] autorelease];
  33. self.navigationItem.rightBarButtonItem = saveButton;
  34. profName.returnKeyType = UIReturnKeyDone;
  35. profName.delegate = self;
  36. className.returnKeyType = UIReturnKeyDone;
  37. className.delegate = self;
  38. time.returnKeyType = UIReturnKeyDone;
  39. time.delegate = self;
  40. room.returnKeyType = UIReturnKeyDone;
  41. room.delegate = self;
  42.  
  43. [self createPicker];
  44. profName.text = newClass.prof;
  45. profName.font = [UIFont systemFontOfSize:22.0];
  46.  
  47. className.text = newClass.title;
  48. className.font = [UIFont systemFontOfSize:22.0];
  49.  
  50. time.text = newClass.time;
  51. time.font = [UIFont systemFontOfSize:22.0];
  52.  
  53. room.text = newClass.room;
  54. room.font = [UIFont systemFontOfSize:22.0];
  55.  
  56. [mypicker selectRow:newClass.building inComponent:0 animated:NO];
  57.  
  58. self.title = newClass.title;
  59. }
  60.  
  61. - (void)saveAction:(id)sender{
  62. newClass.title = className.text;
  63. newClass.prof = profName.text;
  64. newClass.room = room.text;
  65. newClass.time = time.text;
  66. newClass.building = [mypicker selectedRowInComponent:0];
  67.  
  68. [self.navigationController popViewControllerAnimated:YES];
  69. }
  70.  
  71. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
  72. // Dismiss the keyboard when the view outside the text field is touched.
  73. [profName resignFirstResponder];
  74. [className resignFirstResponder];
  75. [time resignFirstResponder];
  76. [room resignFirstResponder];
  77. }
  78.  
  79. - (BOOL)textFieldShouldReturn:(UITextField *)textField{
  80. if ( textField == profName )
  81. {
  82. [profName resignFirstResponder];
  83. }
  84. if ( textField == className )
  85. {
  86. [className resignFirstResponder];
  87. }
  88. if ( textField == room )
  89. {
  90. [room resignFirstResponder];
  91. }
  92. if ( textField == time )
  93. {
  94. [time resignFirstResponder];
  95. }
  96. return YES;
  97. }
  98.  
  99. -(void)createPicker{
  100.  
  101. pickerArray = [[NSArray arrayWithObjects:@"Art Building (ART)" , @"Athletic Academic Center (AAC)" , @"Athletic Center (ATHC)" , @"Athletic Office Building (ATH)" ,
  102. @"Auditorium Building (AUDB)" , @"Bain Hall (BAIN)" , @"Biology Building (BIOL)" , @"Bruce Hall (BRUC)" , @"Building B (MGVB)" , @"Building C (MGVC)" ,
  103. @"Building P (MGVP)" , @"Business Administration Building (BUSI)" , @"Chemistry Building (CHEM)" , @"Chestnut Hall (CHNT)" , @"Chilton Hall (CHIL)" ,
  104. @"Clark Hall (CLAR)" , @"Coliseum (COL)" , @"College Inn (CINN)" , @"Crumley Hall (CRUM)" , @"Curry Hall (CURY)" , @"Discovery Park ( Formerly Research Park ) (NTRP)" ,
  105. @"Eagle Point Intramural Rec Sports Fields (EPRS)" , @"Eagle Student Services Center (ESSC)" , @"East Classroom Building (ECB)" , @"East Classroom Building (SOFT)" ,
  106. @"Environmental Education, Science & Technology (ENV)" , @"Facilities Complex (PLAN)" , @"Fouts Field (STAD)" , @"Fraternity Row (ROWF)" , @"Free Speech Area (FRSA)" ,
  107. @"Gateway Center (GATE)" , @"General Academic Building (GAB)" , @"Goolsby Chapel (CHAP)" , @"Hickory Hall (HKRY)" , @"Highland Hall (HIGH)" , @"Honors Hall (HNRS)" ,
  108. @"Hurley Administration Building (ADMN)" , @"Information Sciences Building (ISB)" , @"Intramural Fields (INTR)" , @"Ken Bahnsen Gym (MGYM)" , @"Kendall Hall (KEND)" ,
  109. @"Kerr Hall (KERR)" , @"Language Building (LANG)" , @"Legends Hall (LGDS)" , @"Library Annex (LANX)" , @"Library Mall (LMAL)" ,
  110. @"Lovelace Stadium - Mean Green Village Softball Field (SOFT)" , @"Lyceum (LYCM)" , @"Lyric Theater - Murchison Performing Arts Center (Lyric-PAC)" , @"Maple Hall (MAPL)" ,
  111. @"Marquis Hall (MARQ)" , @"Masters Hall (MAST)" , @"Matthews Hall (MATT)" , @"Matthews Hall Annex (MHA)" , @"McConnell Hall (MCON)" ,
  112. @"Mean Green Office Complex and Gym (MGOG)" , @"Mean Green Softball and Golf Practice Facility (MGSG)" , @"Mean Green Village Soccer Stadium (SOCR)" ,
  113. @"Mozart Square (MOZA)" , @"Murchison Performing Arts Center (PAC)" , @"Music Annex (MUSA)" , @"Music Building (MUSI)" , @"Music Practice North (MPN)" ,
  114. @"Music Practice South (MPS)" , @"Oak Street Hall (OSH)" , @"Oak Street Hall Annex (OSHA)" , @"Parking Garage (PARK)" , @"Performing Arts Center Annex (PACX)" ,
  115. @"Physical Education Building (PEB)" , @"Physical Education Building - Field (PEBF)" , @"Physics Building (PHYS)" , @"Pohl Recreation Center (RECS)" ,
  116. @"Police Sub Station (MGPS)" , @"Radio, TV, Film & Performing Arts Building (RTFP)" , @"Recreational Sports Complex (recsports)" , @"Santa Fe Square (SFE)" ,
  117. @"Science Research Building (SRB)" , @"Scoular Hall (SCOU)" , @"Shrader Pavilion (PAV)" , @"Sorority Row (ROWS)" , @"Speech and Hearing Clinic (SPHS)" ,
  118. @"Sports Medicine/Fitness Facility (WGHT)" , @"Stovall Hall (STOV)" , @"Student Athlete Academic Center (SAAC)" , @"Student Health & Wellness Center (HEAL)" ,
  119. @"Sullivant Public Safety Center (POLI)" , @"Tennis Courts (WTEN)" , @"Terrill Hall (TH)" , @"The Campus Greens (CGRN)" , @"Traditions Field (TRDF)" ,
  120. @"Traditions Hall (TRAD)" , @"University Services Building (USB)" , @"University Union (UU)" , @"Victory Hall (VICT)" , @"Waranch Tennis Complex (TENN)" ,
  121. @"West Hall (WEST)" , @"West Tennis Courts (WSTN)" , @"Willis Library (LIBR)" , @"Winspear Hall - Murchison Performing Arts Center (Winspear-PAC)" , @"Wooten Hall (WH)", nil] retain];
  122. mypicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 200.0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height)];
  123. mypicker.delegate = self;
  124. mypicker.showsSelectionIndicator = YES;
  125.  
  126. [self.view addSubview:mypicker];
  127.  
  128. }
  129.  
  130. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
  131. return 1;
  132. }
  133.  
  134. - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
  135. return [pickerArray count];
  136. }
  137.  
  138. - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
  139. NSString *returnStr = [pickerArray objectAtIndex:row];
  140. return returnStr;
  141. }
  142.  
  143. - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
  144.  
  145. }
  146.  
  147. -(IBAction)viewMap:(id)sender{
  148. testAppDelegate *appdelegate = (testAppDelegate *)[[UIApplication sharedApplication] delegate];//create a delegate object
  149. appdelegate.building = [mypicker selectedRowInComponent:0];
  150. appdelegate.first = NO;
  151. if (newViewMap == nil){
  152. Map *nView =[[Map alloc] initWithNibName:@"Map" bundle:nil];
  153. self.newViewMap = nView;
  154. [nView release];
  155. }
  156.  
  157. [self.navigationController pushViewController:newViewMap animated:YES];
  158. }
  159.  
  160. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  161. // Return YES for supported orientations
  162. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  163. }
  164.  
  165. - (void)didReceiveMemoryWarning {
  166. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  167. // Release anything that's not essential, such as cached data
  168. }
  169.  
  170. - (void)dealloc {
  171. [newClass release];
  172. [profName release];
  173. [className release];
  174. [room release];
  175. [mypicker release];
  176. [pickerArray release];
  177. [time release];
  178. [newViewMap release];
  179. [super dealloc];
  180. }
  181.  
  182.  
  183. @end
Add Comment
Please, Sign In to add comment