Download presentation
Presentation is loading. Please wait.
Published byBuddy Williamson Modified over 8 years ago
1
Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 12 Summer 2011
2
Announcments Program 5 due Wednesday Midterm Exam Thursday Project Proposals due… Ch8 TableViews deferred …. Lec 12 Pickers
3
Topics Pickers UIDatePicker –NSDate class Custom Pickers –Data source –synchronization Plists Lec 12 Pickers
4
Pickers - 1 What/why? A tab bar picker –example Lec 12 Pickers
5
Tab 3 Date Picker Ivars? Properties? Outlets? Actions? *note: –Date/Time format Lec 12 Pickers
6
DatePicker Change datePicker Mode buttonPressed details –Raw date – use description –Formatted date: NSDateFormatter Lec 12 Pickers
7
NSDateFormatter Formatting dates converting string dates –setDateStyle –setDateFormat –Examples: setDateStyle:NSDateFormatterShortStyle setDateFormat:@"dd-MM-yyyy” Lec 12 Pickers
8
DatePicker Setting the datePicker date - (void) setDate: (NSDate*) date animated:(BOOL)animated Where? Lec 12 Pickers
9
Tab 4 Custom Picker Ivars? Properties? Outlets? Actions? *note: –Date/Time format Lec 12 Pickers
10
Tab 4 Custom Picker Terminology: rows, components text or images (views) Lec 12 Pickers
11
Tab 4 Custom Picker Delegates again –Set in IB UIPickerViewDelegate UIPickerViewDataSource picker will ‘request’ data to be displayed as it is needed from the delegate. Lec 12 Pickers
12
Custom Picker Data source #1. Static NSArray –Initialized where? Data source methods: - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [cityData count]; } Lec 12 Pickers
13
Tab 4 Custom Picker PickerView Delegate methods: -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component Optional: --(void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { Lec 12 Pickers
14
Custom Picker Data source #2 Property lists – app data files Creating a property list. - (void) loadCityDataFromPList { NSBundle *bundle = [NSBundle mainBundle]; NSString *plistPath = [bundle pathForResource: @"cityData" ofType:@"plist"]; NSArray* cityDataArray = [[NSArray alloc] initWithContentsOfFile:plistPath]; self.cityData = cityDataArray; [cityDataArray release] ;} Called from where? Lec 12 Pickers
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.