i have added a pickerview from interface builder.i am using this method to show data like this....
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (pickerView == SpotPickerView) // don't show selection for the custom picker
{
// report the selection to the UI label
label.text = [NSString stringWithFormat:#"%d - %# - %d",[pickerView selectedRowInComponent:0],
[RowArray objectAtIndex:[pickerView selectedRowInComponent:1]],
[pickerView selectedRowInComponent:2]];
}
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *returnStr = #"";
if (pickerView == SpotPickerView)
{
if (component == 0)
{
returnStr = [[NSNumber numberWithInt:row+1] stringValue];
}
else if(component==1)
{
returnStr = [RowArray objectAtIndex:row];
}
else
{
returnStr =[[NSNumber numberWithInt:row+1] stringValue];
}
}
return returnStr;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
CGFloat componentWidth = 0.0;
if (component == 0)
componentWidth = 90.0;
else if (component == 1)
componentWidth = 100.0;
else
componentWidth = 90.0;
return componentWidth;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return 40.0;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
int count;
if (component == 0)
count = 15;
else if (component == 1)
count=[RowArray count];
else
count = 100;
return count;
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 3;
}
here is the RowArray
- (void)viewDidLoad {
RowArray = [[NSArray arrayWithObjects:
#"A", #"B", #"C",
#"D", #"E", #"F", #"G",#"H",#"I",#"J",#"K",#"L",#"M",#"N",#"O",#"P",#"Q",#"R",#"S",#"T",
#"U",#"V",#"W",#"X",#"Y",#"Z",
nil] retain];
}
but selecting the first row shows this.
i need to store the values in database so i need the 1 instead of zero.
also how do i reset my picker view.means when i click on a button it automatically comes to the 0th index in each column.
label.text = [NSString stringWithFormat:#"%d - %# - %d",[pickerView selectedRowInComponent:0],
[RowArray objectAtIndex:[pickerView selectedRowInComponent:1]],
[pickerView selectedRowInComponent:2]];
This code is retrieving the row number from the selected row in a component. Arrays are zero indexed and the pickerview (probably) uses array's to manage the rows. So, the first row will be 0, the second 1, the third 2 and so on. This is easily solved by doing:
[pickerView selectedRowInComponent:0] + 1
You can select certain rows programmatically by using selectRow:inComponent:animated If you want the select the 0th index in each column just do: [pickerView selectRow:0 inComponent:0 animated:YES] for every component.
Related
I getting crash uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 3 beyond bounds [0 .. 2]' in Objective C
crashlytics issues at this line "label.text = [_addressTypeArray objectAtIndex:row];"
please see the below code and help if possible
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
**- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if (isStateButtonClicked == YES) {
return _stateTypeArray.count;
} else
return _addressTypeArray.count;
}
#pragma mark - UIPickerViewDelegate
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc]init];
label.textColor = [UIColor blackColor];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont fontWithName:kGothamMediumFontName size:17.0];
if (isStateButtonClicked == YES) {
NSString *stateName = [NSString stringWithFormat:#"%# - %#", [[_stateTypeArray objectAtIndex:row] objectForKey:#"StateName"], [[_stateTypeArray objectAtIndex:row] objectForKey:#"StateFullName"]];
label.text = stateName;
}
else {
label.text = [_addressTypeArray objectAtIndex:row];
}
return label;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (pickerView == self.addressTypePickerView)
{
self.addressTypePickerView.hidden = NO;
orderPickerContainerView.hidden = NO;
disableView.hidden = NO;
if (isStateButtonClicked == YES) {
self.stateRow = row;
self.stateTypeSelected = [[_stateTypeArray objectAtIndex:row] objectForKey:#"StateName"];
} else {
self.addressTypeRow = row;
self.addressTypeSelected = [_addressTypeArray objectAtIndex:row];
}
}
if (pickerView == self.stateTypePickerView)
{
self.stateRow = row;
self.stateTypeSelected = [[_stateTypeArray objectAtIndex:row] objectForKey:#"StateName"];
}
[self.addressTypePickerView reloadAllComponents];
self.scrollViewMain.contentSize = CGSizeMake(self.bounds.size.width, 550.0);
}
The issue is your button state. It was changed without telling the picker that it has to reload its data.
Have a look into the code you call for the button. There should be a line calling
reloadallcomponents on the picker.
#import "ProfileViewController.h"
#implementation ProfileViewController{
NSArray *currentArray;
UITextField *currentTextField;
}
#synthesize picker, Feets, Inchs, Weights, Months, Days, Years, HeightValue, WeightValue, DOBValue;
#synthesize scrollView;
int variabla;
// Control the textfield go up when tap the textfield and keyboard coming out
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
CGPoint scrollPoint = CGPointMake(0, textField.frame.origin.y);
[scrollView setContentOffset:scrollPoint animated:YES];
[textField resignFirstResponder];
[picker setHidden:YES];
currentTextField = textField;
NSLog(#"222222");
if (currentTextField == HeightValue)
{
NSLog(#"3333333");
[HeightValue resignFirstResponder];
[picker setHidden:NO];
variabla = 1;
}
else if (currentTextField == WeightValue)
{
NSLog(#"4444444");
[WeightValue resignFirstResponder];
[picker setHidden:NO];
variabla = 2;
}
else if (currentTextField == DOBValue){
NSLog(#"5555555");
[DOBValue resignFirstResponder];
[picker setHidden:NO];
variabla = 3;
}
NSLog(#"variabla %d",variabla);
[picker reloadAllComponents];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"111111");
NSString *path = [[NSBundle mainBundle]pathForResource:#"WeightList" ofType:#"plist"];
Weights = [[NSMutableArray alloc]initWithContentsOfFile:path];
[picker setHidden:YES];
Feets = [[NSMutableArray alloc]initWithObjects:#"0ft", #"1ft", #"2ft", #"3ft", #"4ft", #"5ft", #"6ft", #"7ft", #"8ft", #"9ft",nil];
Inchs = [[NSMutableArray alloc]initWithObjects:#"0in", #"1in", #"2in", #"3in", #"4in", #"5in", #"6in", #"7in", #"8in", #"9in", #"10in", #"11in",nil];
Months = [[NSMutableArray alloc]initWithObjects:#"1", #"2", #"3",nil];
Days = [[NSMutableArray alloc]initWithObjects:#"1", #"2", #"3",nil];
Years = [[NSMutableArray alloc]initWithObjects:#"1", #"2", #"3",nil];
#pragma mark - UIPcikerView DataSource and Delegate method
// returns the number of 'columns' to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
if (variabla == 1){
return 2;
}
else if (variabla == 2){
return 1;
}
else
return 3;
}
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
if (variabla == 1){
if (component == feetComponent)
return [Feets count];
if (component == inchComponent)
return [Inchs count];
}
if (variabla == 2){
return [Weights count];
}
else{
if (component == monthComponent)
return [Months count];
if (component == dayComponent)
return [Days count];
else
return [Years count];
}
}
// set the row text to the textfield
- (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component __TVOS_PROHIBITED{
if (variabla == 1){
if (component == feetComponent)
return Feets[row];
if (component == inchComponent)
return Inchs[row];
}
if (variabla == 2){
return Weights[row];
}
else{
if (component == monthComponent)
return Months[row];
if (component == dayComponent)
return Days[row];
else
return Years[row];
}
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component __TVOS_PROHIBITED{
if (currentTextField == HeightValue){
NSInteger feetRow = [picker selectedRowInComponent:feetComponent];
NSInteger inchRow = [picker selectedRowInComponent:inchComponent];
NSString *feet = Feets[feetRow];
NSString *inch = Inchs[inchRow];
NSString *msg = [[NSString alloc]initWithFormat:#"%# %#", feet, inch];
HeightValue.text = msg;
}
if (currentTextField == WeightValue){
NSInteger weightRow = [picker selectedRowInComponent:weightComponent];
NSString *weight = Weights[weightRow];
NSString *msg2 = [[NSString alloc]initWithFormat:#"%#",weight];
WeightValue.text = msg2;
}
if (currentTextField == DOBValue){
NSInteger monthRow = [picker selectedRowInComponent:monthComponent];
NSInteger dayRow = [picker selectedRowInComponent:dayComponent];
NSInteger yearRow = [picker selectedRowInComponent:yearComponent];
NSString *month = Months[monthRow];
NSString *day = Days[dayRow];
NSString *year = Years[yearRow];
NSString *msg3 = [[NSString alloc]initWithFormat:#"%# / %# / %#", month, day, year];
WeightValue.text = msg3;
}
}
#end
Above is the .m file code. When I run the simulator, the first textfield for the Height is working fine, but in the Weight and Date textfield, the picker view got the exception.
Simulator screen shot
NSRangeException screen shot
Well the exception says Index 5 beyond bounds [0..0]. So that says you have an array of size 1 but are asking it for the object at index 5, which doesn't make sense, so it crashes.
The traceback says that objectAtIndex method is being called from selectedRowInComponent:, which is being called from your didSelectRow:inComponent. So that suggests that you're passing an invalid component number to selectedRowInComponent.
I don't know where weightComponent and month/day/yearComponent are being set, but I'm guessing that they are not being set to 0 and 0, 1, and 2 respectively.
As an aside, I would also add that when you have a picker with labels 0ft, 1ft etc, that you don't keep around all these tables. Instead of creating a table and indexing it, just answer the titleForRow call with return [NSString stringWithFormat:#"%dft",row];
My iOS app populates an SQLlite database (using FMDB) from a web query. There is a UITableView to display this data. Since I started writing the app the size of this db has exploded to about 10,000 records.
My current design is to load the data in an array from the db and then use that in the UITableView. It works, and I have the alphabetized index on the right hand side of the screen for the user to quickly access the data.
The problem of course is it takes 15-20 seconds to load the array. I originally designed this to load every time the user hits the UITableView, but that means 15-20 seconds every time.
Is there a way to only load some of the data in the UITableView while keeping the search functionality and the index?
Can/should I load the array once and reuse it? I have tried but I can't seem to get that work.
As a last resort, I could switch to CoreData but I really don't want to switch horses in midstream.
UITableView implementation:
#import "ContactViewController.h"
#import "ContactDetailViewController.h"
#interface ContactViewController ()
#end
#implementation ContactViewController {
NSMutableArray *_contacts;
UISearchDisplayController *searchController;
BOOL isSearching;
}
- (void)awakeFromNib {
if ([[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.preferredContentSize = CGSizeMake(320.0, 600.0);
}
[super awakeFromNib];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Get array of employees and sections
_contacts = [ContactsDatabase getContacts];
self.sections = [ContactsDatabase getSections:_contacts];
// Set up Search
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
self.filteredContacts = [NSMutableArray array];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
isSearching = FALSE;
// iPad
// self.dtailViewController = (detailViewController
// *)[[self.splitViewController.viewControllers lastObject]
// topViewController];
// Set the back bar button
UIBarButtonItem *backButton =
[[UIBarButtonItem alloc] initWithTitle:#"Contacts"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
self.navigationItem.backBarButtonItem = backButton;
}
#pragma mark - Table View
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
NSInteger tmpRows;
if (tableView == self.searchDisplayController.searchResultsTableView) {
tmpRows = [self.filteredContacts count];
} else {
tmpRows = [[self.sections
valueForKey:[[[self.sections allKeys]
sortedArrayUsingSelector:
#selector(localizedCaseInsensitiveCompare:)]
objectAtIndex:section]] count];
}
return tmpRows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
}
if (isSearching) {
contact *thisContact = [self.filteredContacts objectAtIndex:indexPath.row];
cell.textLabel.text = thisContact.cmpNme;
} else {
contact *thisContact = [[self.sections
valueForKey:[[[self.sections allKeys]
sortedArrayUsingSelector:
#selector(localizedCaseInsensitiveCompare:)]
objectAtIndex:indexPath.section]]
objectAtIndex:indexPath.row];
cell.textLabel.text = thisContact.cmpNme;
}
return cell;
}
#pragma mark - Table Sections
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSInteger tmpCount;
if (isSearching) {
tmpCount = 1;
} else {
tmpCount = [[self.sections allKeys] count];
}
return tmpCount;
}
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {
NSString *tmpString;
if (tableView == self.searchDisplayController.searchResultsTableView) {
tmpString = nil;
} else {
tmpString = [[[self.sections allKeys]
sortedArrayUsingSelector:#selector(localizedCaseInsensitiveCompare:)]
objectAtIndex:section];
}
return tmpString;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:#"showContactDetail"]) {
contact *dtlContact;
if (isSearching) {
dtlContact = [self.filteredContacts
objectAtIndex:self.searchDisplayController.searchResultsTableView
.indexPathForSelectedRow.row];
} else {
dtlContact = [[self.sections
valueForKey:[[[self.sections allKeys]
sortedArrayUsingSelector:
#selector(localizedCaseInsensitiveCompare:)]
objectAtIndex:[self.tableView indexPathForSelectedRow]
.section]]
objectAtIndex:[self.tableView indexPathForSelectedRow].row];
}
self.contactDetailViewController.detailItem = dtlContact;
[[segue destinationViewController] setDetailItem:dtlContact];
}
}
#pragma mark - Right side bar alphabetical index
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
NSArray *tmpTitle;
if (isSearching) {
tmpTitle = nil;
} else {
tmpTitle = [[self.sections allKeys]
sortedArrayUsingSelector:#selector(localizedCaseInsensitiveCompare:)];
}
return tmpTitle;
}
#pragma mark - Search methods
- (void)searchDisplayControllerWillBeginSearch:
(UISearchDisplayController *)controller {
isSearching = TRUE;
self.searchDisplayController.searchBar.showsCancelButton = YES;
[self.tableView reloadSectionIndexTitles];
}
- (void)searchDisplayControllerDidEndSearch:
(UISearchDisplayController *)controller {
isSearching = FALSE;
self.searchDisplayController.searchBar.showsCancelButton = NO;
[self.tableView reloadSectionIndexTitles];
}
- (void)filterContentForSearchText:(NSString *)searchText
scope:(NSString *)scope {
[self.filteredContacts removeAllObjects];
NSPredicate *predicate =
[NSPredicate predicateWithFormat:#"cmpNme contains[c] %#", searchText];
NSArray *tempArray = [_contacts filteredArrayUsingPredicate:predicate];
// Move to filtered array
self.filteredContacts = [NSMutableArray arrayWithArray:tempArray];
self.sections = [ContactsDatabase getSections:_contacts];
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString {
isSearching = TRUE;
[self
filterContentForSearchText:searchString
scope:[self.searchDisplayController.searchBar
.scopeButtonTitles
objectAtIndex:
self.searchDisplayController.searchBar
.selectedScopeButtonIndex]];
return YES;
}
#end
getContacts methods
+ (NSMutableArray *)getContacts {
id tmpDatabasePath = [(AppDelegate *)
[[UIApplication sharedApplication] delegate] databasePathContacts];
NSMutableArray *tmpContacts;
tmpContacts = [[NSMutableArray alloc] init];
FMDatabase *db = [FMDatabase databaseWithPath:tmpDatabasePath];
[db open];
FMResultSet *results =
[db executeQuery:#"SELECT * FROM contacts ORDER by cmpNme"];
while ([results next]) {
contact *thisContact = [contact new];
thisContact.cmpNme = [results stringForColumn:#"cmpNme"];
thisContact.fstNme = [results stringForColumn:#"fstNme"];
thisContact.lstNme = [results stringForColumn:#"lstNme"];
thisContact.cntTyp = [results stringForColumn:#"cnttyp"];
NSString *tst = [results stringForColumn:#"phnNbr"];
thisContact.phnNbr = [NSNumber numberWithInt:[tst intValue]];
thisContact.adr1 = [results stringForColumn:#"adr1"];
thisContact.adr2 = [results stringForColumn:#"adr2"];
thisContact.cty = [results stringForColumn:#"cty"];
thisContact.ste = [results stringForColumn:#"ste"];
tst = [results stringForColumn:#"zip"];
thisContact.zip = [NSNumber numberWithInt:[tst intValue]];
thisContact.ema = [results stringForColumn:#"ema"];
tst = [results stringForColumn:#"id"];
thisContact.id = [NSNumber numberWithInt:[tst intValue]];
[tmpContacts addObject:thisContact];
}
[db close];
return tmpCon
I got a model object that contains movies and actors arrays. I'm trying to populate 2 pickers (1 picker with movies and the other with actors) in the same ViewController. Please help as I'm still learning how it works.
Thanks!
My code is below...
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.model = [[MovieModel alloc] init];
for(int i = 0; i < self.model.count; i++){
NSString *movies = [self.model movieForIndex:i];
NSLog(#" Movie = %#", movies);
}
for(int i = 0; i < self.model.count; i++){
NSString *actors = [self.model actorForIndex:i];
NSLog(#" Actor = %#", actors);
}
}
//This is the place where I'm having issues. Thanks!!!
#pragma mark - Picker View Delegate
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component == 0){
return [self.model movieForIndex: row];
}
else if (component == 1){
return [self.model actorForIndex: row];
}
else
return nil;
}
#pragma mark - Picker View Data Source
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return self.model.count;
}
#end
You'll notice that there's a "pickerView" parameter in the data source methods. This parameter tells you which of your two pickers you're returning data for.
So, let's say you connect your two picker views to two different "IBOutlet" properties or ivars (instance variables), like this:
IBOutlet UIPickerView * moviePicker;
IBOutlet UIPickerView * actorPicker;
Now, in your data source methods, you can do stuff like this:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (pickerView == moviePicker){
return [self.model movieForIndex: row];
}
else if (pickerView == actorPicker){
return [self.model actorForIndex: row];
}
else
return nil;
}
And do something like this for each of the data source methods you want to support. You should be just fine!
First you need to make sure your ViewController implements UIPickerViewDataSource and UIPickerViewDelegate.
You need to add the picker to your view:
UIPickerView *moviesAndActorsPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
[moviesAndActorsPicker setDelegate:self];
[self.view addSubview:moviesAndActorsPicker];
Your picker has two components - 1 for movies and 1 for actors:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;
}
Then set the number of rows for each component:
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
// differentiate which component it is
if (component == 0) { // movies
return movies.count;
}
else { // component = actors
return actors.count;
}
}
You can give each picker a tag as following:
self.firstPicker.tag = 1;
self.secondPicker.tag = 2;
and in the delegate methods of the UIPickerView:
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
if(pickerView.tag)
return self.firstArray.count;
else
return self.secondArray.count;
}
And so on
when I change my picker1, it was supposed to reload my picker2, but only occurs when I scrolls it. What can I do? Thanks!
#implementation ViewController
#synthesize picker1, array1, arrayApple, arraySamsung, picker2, array2;
- (void)viewDidLoad
{
[super viewDidLoad];
array1 = [[NSMutableArray alloc] initWithObjects:#"Apple", #"Samsung",nil];
arrayApple = [[NSMutableArray alloc] initWithObjects: #"iPhone 5", #"iPad", #"iPod Touch", #"MacBook Pro", nil];
arraySamsung = [[NSMutableArray alloc] initWithObjects: #"Galaxy Tab", #"Galaxy S3", #"Galaxy S", #"Galaxy 5", nil];
self.array2 = self.arrayApple;
[picker1 reloadAllComponents];
[picker2 reloadAllComponents];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
//Picker View Methods
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
//NSLog(#"Selected Index: %#. Index of selected color: %i", [array1 objectAtIndex:row], row);
if(pickerView == self.picker1) {
if(row == 1) {
[self.array2 removeAllObjects];
self.array2 = self.arraySamsung;
[picker2 reloadAllComponents];
NSLog(#"%#", picker2);
}
}
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
if (pickerView == self.picker1) {
return [array1 count];
} else {
return [array2 count];
}
return 0;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (pickerView == self.picker1) {
return [self.array1 objectAtIndex:row];
} else {
return [self.array2 objectAtIndex:row];
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
Try this
if(row == 1) {
self.array2 = self.arraySamsung;
} else {
self.array2 = self.arrayApple;
}
[picker2 reloadAllComponents];
NSLog(#"%#", picker2);