I have a UIPickerView in nib and three textfields. I am trying to display same pickerview for all three textfields. However, same data is displayed in the pickerview for all the three textfields. The delegate method is called only the first time. I think this is mainly because since the pickerView is in the nib it gets allocated only once when view loads. So how do i fix this?
You must reload pickerview data.
[self.picker reloadAllComponents]; //Reloading every component
[self.picker reloadComponent:0]; // Reloading specific component
Related
I am working on a simple UI, but am running into trouble with addSubview calls made after a removeFromSuperview.
In my viewController I have an IBOutlet UITableView
#property (strong, nonatomic) IBOutlet UITableView *tableView;
Depending on the state of the data, I remove the tableview from my viewControllers view.
[self.tableView removeFromSuperview];
So far so good, the view is removed. When using the debugger, I can still see that my viewController has a valid handle to the tableview. The problem starts on the next line when I call addSubview.
[self.view addSubview:self.tableView];
[self.tableView setDataSource:studyResult];
[self.tableView reloadData];
It seems to do nothing and I can't see any change in the UI. I have tried to set the frame on the tableView and still no results.
Have any of you seen this behavior?
Joe
Hi Joe can you give me more code for see what are you going? what I get, is that you have your control and a tableview view inside that you want to shot just when you have your array with the data? if is like that why you don't set Hide the tableview when you haven't the data? every time that you refresh the data for the table you have also to use the method reloadData for refresh the table
Depending on the state of the data, I remove the tableview from my viewControllers view.
Consider segueing to another view controller with a table view instead of swapping out table views in a single view controller. Or, if the new data is a subset of the old data, then leave the table view in place and filter its data.
This issue is driving me crazy. I have a UIPickerView that I loaded in viewDidLoad, and I need to initialize the selected row that is to appear on the screen. My code is as follows:
self.pickerSkins.delegate = self;
[self.pickerSkins reloadAllComponents];
NSLog(#"%d", [self.pickerSkins numberOfRowsInComponent:0]);
[self.pickerSkins selectRow:1 inComponent:0 animated:NO];
I have put this in viewDidLoad. NSLog logs a value of 2. However, the selected row that pops up is always the first row and not the second.
If I put the selectRow in viewWillAppear, it also doesn't work.
If I put the selectRow in viewDidAppear, the PickerView appears and then goes to the second row.
UPDATE: If I have more than 2 rows, the method works correctly from viewDidLoad, unless I am scrolling to the last row. The method never works in viewDidLoad or viewWillAppear if I am scrolling to the last row. Any idea why this is? Thanks.
How do I get the selected row to be the second row before the view appears?
Thanks.
I have a UITableViewController that allows for adding to it's cells through another TableviewController where the user can enter their data. I am passing the NSString data back to the first TableViewController properly as the NSLog states. However, the first TableViewController is not re-firing. I believe this is caused because I am using a modal transition. Would somebody explain to me how to make a UITableViewController re-fire with modal transitions?
in
-(void)viewWillAppear:(BOOL)animated
after adding to the table input array(datasource )
call
[tableView reloadData];
This is the first time I have tried to do this and I understand the concept of what I am trying to do but just not 100% sure on how to execute it.
I have a main view and a sub view.. the main view has several custom uitableviewcells each with a single textlabel. when the cell is selected it loads the subview onto the navigational stack, their is a list of standard uitableviews that I have loaded with values from the database.
When you select one of these uitableviewcells in the sub view, I want to capture that value pop the current view from the stack and then load the selected value of the subview into the main tableviews cell that was originally selected..
In the sub view I am thinking something along the lines of
MainViewController *mvc = [[MainViewController alloc] initWithNibName:#"MainViewController" objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:mvc animated:YES];
[mvc release];
But this obviously this isnt passing any values around...
You want to use delegation, if you don't know how to use it, this link might help:
http://cocoadevcentral.com/articles/000075.php
So the general idea is that your main view will be the delegate of your subview, and the subview will tell it's delegate when a cell was tapped and pass in that variable (for example: [delegate cellChanged:cell];), then the main view (the delegate of the subview) will handle that.
I've got the problem that tableview methods are not called the first time the tableview is shown.
If I switch back to the previous view, and then click the button to show the tableview again, the methods are called this time.
I should say that I show an actionsheet while the tableview is loading.
The actionsheet I call in the ViewWillAppear method.
i fixed it by adding [self.tableView reloadData] after dismissing the actionsheet. i don't know if it's the proper way, but it somehow works.