Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "EditClass.h"
- #import "testAppDelegate.h"
- @interface EditClass (Private)
- - (void)createPicker;
- @end
- @implementation EditClass
- @synthesize newClass, profName, className, mypicker, pickerArray, time, room, newViewMap;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
- // Initialization code
- }
- return self;
- }
- /*
- Implement loadView if you want to create a view hierarchy programmatically
- - (void)loadView {
- }
- */
- // If you need to do additional setup after loading the view, override viewDidLoad.
- - (void)viewDidLoad {
- [self.view setBackgroundColor:[UIColor blackColor]];
- UIBarButtonItem *saveButton = [[[UIBarButtonItem alloc]
- initWithTitle:NSLocalizedString(@"Save Changes", @"")
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(saveAction:)] autorelease];
- self.navigationItem.rightBarButtonItem = saveButton;
- profName.returnKeyType = UIReturnKeyDone;
- profName.delegate = self;
- className.returnKeyType = UIReturnKeyDone;
- className.delegate = self;
- time.returnKeyType = UIReturnKeyDone;
- time.delegate = self;
- room.returnKeyType = UIReturnKeyDone;
- room.delegate = self;
- [self createPicker];
- profName.text = newClass.prof;
- profName.font = [UIFont systemFontOfSize:22.0];
- className.text = newClass.title;
- className.font = [UIFont systemFontOfSize:22.0];
- time.text = newClass.time;
- time.font = [UIFont systemFontOfSize:22.0];
- room.text = newClass.room;
- room.font = [UIFont systemFontOfSize:22.0];
- [mypicker selectRow:newClass.building inComponent:0 animated:NO];
- self.title = newClass.title;
- }
- - (void)saveAction:(id)sender{
- newClass.title = className.text;
- newClass.prof = profName.text;
- newClass.room = room.text;
- newClass.time = time.text;
- newClass.building = [mypicker selectedRowInComponent:0];
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
- // Dismiss the keyboard when the view outside the text field is touched.
- [profName resignFirstResponder];
- [className resignFirstResponder];
- [time resignFirstResponder];
- [room resignFirstResponder];
- }
- - (BOOL)textFieldShouldReturn:(UITextField *)textField{
- if ( textField == profName )
- {
- [profName resignFirstResponder];
- }
- if ( textField == className )
- {
- [className resignFirstResponder];
- }
- if ( textField == room )
- {
- [room resignFirstResponder];
- }
- if ( textField == time )
- {
- [time resignFirstResponder];
- }
- return YES;
- }
- -(void)createPicker{
- pickerArray = [[NSArray arrayWithObjects:@"Art Building (ART)" , @"Athletic Academic Center (AAC)" , @"Athletic Center (ATHC)" , @"Athletic Office Building (ATH)" ,
- @"Auditorium Building (AUDB)" , @"Bain Hall (BAIN)" , @"Biology Building (BIOL)" , @"Bruce Hall (BRUC)" , @"Building B (MGVB)" , @"Building C (MGVC)" ,
- @"Building P (MGVP)" , @"Business Administration Building (BUSI)" , @"Chemistry Building (CHEM)" , @"Chestnut Hall (CHNT)" , @"Chilton Hall (CHIL)" ,
- @"Clark Hall (CLAR)" , @"Coliseum (COL)" , @"College Inn (CINN)" , @"Crumley Hall (CRUM)" , @"Curry Hall (CURY)" , @"Discovery Park ( Formerly Research Park ) (NTRP)" ,
- @"Eagle Point Intramural Rec Sports Fields (EPRS)" , @"Eagle Student Services Center (ESSC)" , @"East Classroom Building (ECB)" , @"East Classroom Building (SOFT)" ,
- @"Environmental Education, Science & Technology (ENV)" , @"Facilities Complex (PLAN)" , @"Fouts Field (STAD)" , @"Fraternity Row (ROWF)" , @"Free Speech Area (FRSA)" ,
- @"Gateway Center (GATE)" , @"General Academic Building (GAB)" , @"Goolsby Chapel (CHAP)" , @"Hickory Hall (HKRY)" , @"Highland Hall (HIGH)" , @"Honors Hall (HNRS)" ,
- @"Hurley Administration Building (ADMN)" , @"Information Sciences Building (ISB)" , @"Intramural Fields (INTR)" , @"Ken Bahnsen Gym (MGYM)" , @"Kendall Hall (KEND)" ,
- @"Kerr Hall (KERR)" , @"Language Building (LANG)" , @"Legends Hall (LGDS)" , @"Library Annex (LANX)" , @"Library Mall (LMAL)" ,
- @"Lovelace Stadium - Mean Green Village Softball Field (SOFT)" , @"Lyceum (LYCM)" , @"Lyric Theater - Murchison Performing Arts Center (Lyric-PAC)" , @"Maple Hall (MAPL)" ,
- @"Marquis Hall (MARQ)" , @"Masters Hall (MAST)" , @"Matthews Hall (MATT)" , @"Matthews Hall Annex (MHA)" , @"McConnell Hall (MCON)" ,
- @"Mean Green Office Complex and Gym (MGOG)" , @"Mean Green Softball and Golf Practice Facility (MGSG)" , @"Mean Green Village Soccer Stadium (SOCR)" ,
- @"Mozart Square (MOZA)" , @"Murchison Performing Arts Center (PAC)" , @"Music Annex (MUSA)" , @"Music Building (MUSI)" , @"Music Practice North (MPN)" ,
- @"Music Practice South (MPS)" , @"Oak Street Hall (OSH)" , @"Oak Street Hall Annex (OSHA)" , @"Parking Garage (PARK)" , @"Performing Arts Center Annex (PACX)" ,
- @"Physical Education Building (PEB)" , @"Physical Education Building - Field (PEBF)" , @"Physics Building (PHYS)" , @"Pohl Recreation Center (RECS)" ,
- @"Police Sub Station (MGPS)" , @"Radio, TV, Film & Performing Arts Building (RTFP)" , @"Recreational Sports Complex (recsports)" , @"Santa Fe Square (SFE)" ,
- @"Science Research Building (SRB)" , @"Scoular Hall (SCOU)" , @"Shrader Pavilion (PAV)" , @"Sorority Row (ROWS)" , @"Speech and Hearing Clinic (SPHS)" ,
- @"Sports Medicine/Fitness Facility (WGHT)" , @"Stovall Hall (STOV)" , @"Student Athlete Academic Center (SAAC)" , @"Student Health & Wellness Center (HEAL)" ,
- @"Sullivant Public Safety Center (POLI)" , @"Tennis Courts (WTEN)" , @"Terrill Hall (TH)" , @"The Campus Greens (CGRN)" , @"Traditions Field (TRDF)" ,
- @"Traditions Hall (TRAD)" , @"University Services Building (USB)" , @"University Union (UU)" , @"Victory Hall (VICT)" , @"Waranch Tennis Complex (TENN)" ,
- @"West Hall (WEST)" , @"West Tennis Courts (WSTN)" , @"Willis Library (LIBR)" , @"Winspear Hall - Murchison Performing Arts Center (Winspear-PAC)" , @"Wooten Hall (WH)", nil] retain];
- mypicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 200.0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height)];
- mypicker.delegate = self;
- mypicker.showsSelectionIndicator = YES;
- [self.view addSubview:mypicker];
- }
- - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
- return 1;
- }
- - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
- return [pickerArray count];
- }
- - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
- NSString *returnStr = [pickerArray objectAtIndex:row];
- return returnStr;
- }
- - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
- }
- -(IBAction)viewMap:(id)sender{
- testAppDelegate *appdelegate = (testAppDelegate *)[[UIApplication sharedApplication] delegate];//create a delegate object
- appdelegate.building = [mypicker selectedRowInComponent:0];
- appdelegate.first = NO;
- if (newViewMap == nil){
- Map *nView =[[Map alloc] initWithNibName:@"Map" bundle:nil];
- self.newViewMap = nView;
- [nView release];
- }
- [self.navigationController pushViewController:newViewMap animated:YES];
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
- // Release anything that's not essential, such as cached data
- }
- - (void)dealloc {
- [newClass release];
- [profName release];
- [className release];
- [room release];
- [mypicker release];
- [pickerArray release];
- [time release];
- [newViewMap release];
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment