I want to use my uipicker to initialize a 5character string representation of a hex number. So in other words I need each component of the uipicker to show 0-9,A-F dose anyone have an idea on how this could be done or if it is even possible?
currently this is how my code looks. //.h
//...
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate, UIPickerViewDelegate, UIPickerViewDataSource> {
IBOutlet UIPickerView *hexPicker;
//...
//.m
//.....
- (void)viewDidLoad {
//hexPicker = [[UIPickerView alloc] init];
//initalise icker at bottom of screen
hexPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 244, 320, 216)];
hexPicker.delegate = self;
hexPicker.dataSource = self;
hexPicker.showsSelectionIndicator = YES;
[self.view addSubview:hexPicker];
[super viewDidLoad];
}
//.....
#pragma mark UIPickerViewDelegate methods
- (NSString*)pickerView:(UIPickerView*)pv titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
//This only shows as digits/integers
//return [NSString stringWithFormat:@"%d",row];
//this shows those digits as hex
[[NSString stringWithFormat:@"%x",row] uppercaseString];
}
#pragma mark UIPickerViewDataSource methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pv
{
return 5;
}
- (NSInteger)pickerView:(UIPickerView*)pv numberOfRowsInComponent:(NSInteger)component
{
return 16;
}
//...
Also how am I able to load the picker at the bottom of the screen. Thanks. Updated code to represent this part Updated pickerView:titleForRow:forComponent: method for hex representation this now dose what it is intended to do :).