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

  • SEARCH
  • Home
  • 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 6943379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:08:53+00:00 2026-05-27T13:08:53+00:00

I got problems with reload component in UIPickerView. Here is my code: on my

  • 0

I got problems with reload component in UIPickerView. Here is my code:

on my header file (.h):

@interface GoToAyatViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>{
    IBOutlet UIPickerView *pickerViewObj;
}
@property (nonatomic, retain) IBOutlet UIPickerView *pickerViewObj;

@end

on my implementation (.m):

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) { 
        // Custom initialization.
        ratusan = [[NSMutableArray alloc] initWithObjects:@"      0",@"      1",nil];
        puluhan = [[NSMutableArray alloc] initWithObjects:@"      0",@"      1",@"      2",
                @"      3",@"      4", @"      5", 
                @"      6", @"      7", @"      8", 
                @"      9",nil];
        satuan = [[NSMutableArray alloc] initWithObjects:@"      0",@"      1",@"      2",
                  @"      3",@"      4", @"      5", 
                  @"      6", @"      7", @"      8", 
                  @"      9",nil];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    pickerViewObj = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 250, 400, 80)];
    pickerViewObj.showsSelectionIndicator = YES;
    pickerViewObj.dataSource = self;
    pickerViewObj.delegate = self;  
    [self.pickerViewObj selectRow:2 inComponent:0 animated:NO];
    [pasalTypeButton setBackgroundColor:[UIColor blueColor]];
    self.isPasal = YES;
    self.title = self.kitab;
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {

    return kPICKERCOLUMN;
    NSLog(@"numberOfComponentsInPickerView jalan");
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    NSLog(@"numberOfRowsInComponent jalan");
    if (component==0){
        return [ratusan count];
    }else if (component == 1) {
        return [puluhan count];
    }else{
        return [satuan count];
    }

}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    NSLog(@"set title run");
    switch (component) 
    {
        case 0:
            return [ratusan objectAtIndex:row];
            //break;
        case 1:
            return [puluhan objectAtIndex:row];
            //break;
        case 2:
            return [satuan objectAtIndex:row];
            //break;
    }
    return nil;
}

and in the implementation i put ibaction to set new value for 1st component on my uipickerview and fire reloadallcomponents:

-(IBAction) showAyat
{
self.ratusan = nil;
    self.ratusan = [[NSMutableArray alloc] initWithObjects:@"      0",@"      1",@"      2",nil];
    [self.pickerViewObj reloadAllComponents];
    NSLog(@"total ratusan=%d", [self.pickerViewObj numberOfRowsInComponent:0]);
}

here the picture of my nib setting in case i do wrong in setting delegate or datasource.

xib setting

by code above when i fire (tap button) showAyat method, it doesnt change the valu of my uipickerview at runtime, but i can see numberOfRowsInComponent:0 has already changed to 3 (before 2) using NSLog. I dont know what is wrong with my pickerview doesnt update the display.
Please someone help me out here.

  • 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-27T13:08:54+00:00Added an answer on May 27, 2026 at 1:08 pm

    Problem:

    You are creating two UIPickerView.

    • One in Xib (connecting as IBOutlet).
    • Second in code (inside viewDidLoad: method).

    Both get data values from your delegate.

    Since the picker created in Xib loses connection to the pickerViewObj variable when you initialize another second UIPickerView in code. So the UIPickerView presented at the time doesn’t changes its value.

    Solution:

    Remove the code for creating UIPickerView from code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got problems installating the VMWARE ESXi Server. The Installation finishes without any error
I've got problems with setting focus to an input field after validating it. I've
I got some problems with finding a bug in php/mysql application, and I wonder
I got some problems with EOF and stdio in a communication pipeline between a
We've got some problems with an external company trying in integrate into a WCF
I've got some problems on a .NET site where both Latin (åäö) and Latvian
I am just starting with C++ and got some problems in understanding how the
i'm new to java and i got some problems. i'm developping a web application
I'm working on a online game. I got some problems with inserting new data
I've got a new site setup using CMSMadeSimple (PHP based) but I'm having problems

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.