Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6017841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:11:16+00:00 2026-05-23T03:11:16+00:00

I want to use my uipicker to initialize a 5character string representation of a

  • 0

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 :).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:11:16+00:00Added an answer on May 23, 2026 at 3:11 am

    Your delegate method pickerView:titleForRow:forComponent: should be like,

    - (NSString*)pickerView:(UIPickerView*)pv titleForRow:(NSInteger)row forComponent:(NSInteger)component
    {
        return [NSString stringWithFormat:@"%X",row];
    }
    

    When you want to extract the string do this,

    NSString *hexString = [NSString stringWithFormat:@"%X%X%X%X%X", [hexPicker selectedRowInComponent:0], [hexPicker selectedRowInComponent:1], [hexPicker selectedRowInComponent:2], [hexPicker selectedRowInComponent:3], [hexPicker selectedRowInComponent:4]];
    

    That should give you the hex string you need.

    Addendum

    To support infinite scroll, you will just need to return a sufficiently huge number for the number of rows like this,

    - (NSInteger)pickerView:(UIPickerView*)pv numberOfRowsInComponent:(NSInteger)component
    {
        return 160000;
    }
    

    and during initialization use the selectRow:inComponent:animated: method to select a row somewhere in the middle so that user can scroll either ways.

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
    
        for ( int i = 0; i < hexPicker.numberOfComponents; i++ ) {
            [hexPicker selectRow:80000 inComponent:i animated:NO];
        }
    }
    

    You will also need to change the methods mentioned above,

    - (NSString*)pickerView:(UIPickerView*)pv titleForRow:(NSInteger)row forComponent:(NSInteger)component
    {
        return [NSString stringWithFormat:@"%X",(row % 16)];
    }
    

    And the hex string extraction would be,

    NSString *hexString = [NSString stringWithFormat:@"%X%X%X%X%X", ([hexPicker selectedRowInComponent:0] % 16), ([hexPicker selectedRowInComponent:1] % 16), ([hexPicker selectedRowInComponent:2] % 16), ([hexPicker selectedRowInComponent:3] % 16), ([hexPicker selectedRowInComponent:4] % 16)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the current selected row for UIPicker? I want to use
I need to use HTML comments to store specific data, but I don't want
I want use $.ajax get a url string from a xml file ,then with
I want use a stored procedure to update multiple tables in a db. Each
I'm want use $ macro in groovy GString. When i'm wrote this code ['cdata','tdata'].each
I want show UITableView, but i want use it with Page Control. For example
I want use groovy findAll with my param to filtering closure filterClosure = {
i want use some data from a website with web service. i have a
I want use JQuery mobile for the front-end of my mobile application, but I
I want use jQuery in my project. I know the javascript_include_tag calls the jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.