Revision: 63816
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 8, 2013 03:07 by BreadicalMD
Initial Code
#pragma mark -
#pragma Picker View Data Source methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
//Return the number of components
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
//Return the number of rows in the component
return 1;
}
#pragma mark -
#pragma Picker View Delegate methods
//Set the dimensions of the picker view.
/*
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return 40.0f;
}
*/
/*
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
return 200.f;
}
*/
//The methods in this group are marked @optional. However, to use a picker view, you must implement either the pickerView:titleForRow:forComponent: or the pickerView:viewForRow:forComponent:reusingView: method to provide the content of component rows.
//If both pickerView:titleForRow:forComponent: and pickerView:attributedTitleForRow:forComponent: are implemented, attributed title is favored.
// Return a string representing the title for the given row.
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
//return [dataSource objectAtIndex:row];
return @"Nil";
}
//Return a view to use for the given row:.
//reusingView is A view object that was previously used for this row, but is now hidden and cached by the picker view.
//If the previously used view is good enough, return that.
//The picker view centers the returned view in the rect for the given row.
/*
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
if (view != nil)
{
return view;
}
else
{
UIView* view;
view.backgroundColor = [UIColor whiteColor];
return view;
}
}
*/
//Return a styled sring representing the title for the given row.
/*
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component
{
//return [dataSource objectAtIndex:row];
return (NSAttributedString*)@"Nil";
}
*/
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
//Do something when the row is selected.
}
Initial URL
Initial Description
This is a template for a UIPickerView delegate and data source. Implement these methods to manage UIPickerViews.
Initial Title
UIPickerView Delegate and Data Source template
Initial Tags
template
Initial Language
Objective C