0
我做了4個pickerviews,每個都有15個對象,我實現了所有的委託方法。返回1個組件數,行數也是正確的,但是在行方法行總是0,pickerview不是diplayed.help我在找到我錯在哪裏。 這裏是我的代碼uipickerview不顯示行數> 0的數據
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
NSLog(@"In Number Of Components Method\n");
int numberOfComponents = 1;
return numberOfComponents;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent(NSInteger)component {
NSMutableArray* keysArray = [[NSMutableArray alloc] init];
NSMutableArray* valuesArray = [[NSMutableArray alloc]init];
DBManager* dbManger = [[DBManager alloc] init];
//companyName,city,category,postalCode
NSInteger count = 0;
switch (pickerView.tag) {
case 0:
if (![selectBusinessTextField.text isEqualToString:@""]) {
[keysArray addObject:@"category"];
[valuesArray addObject:selectBusinessTextField.text];
}
if (![selectCityTextField.text isEqualToString:@""]) {
[keysArray addObject:@"city"];
[valuesArray addObject:selectCityTextField.text];
}
if (![selectPostalCodeTextField.text isEqualToString:@""]) {
[keysArray addObject:@"postalCode"];
[valuesArray addObject:selectPostalCodeTextField.text];
}
if (keysArray.count) {
alternateArrayFoBusinessNamesArray = [dbManger fetchColumn:@"companyName" whereKeysAre:keysArray andValuesAre:valuesArray];
else
alternateArrayFoBusinessNamesArray = [dbManger fetchColumn:@"companyName"];
}
count = alternateArrayFoBusinessNamesArray.count;
break;
}
return count;
}
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel* pickerItemLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textFieldWidth, 40)];
[pickerItemLabel setFont:[UIFont fontWithName:appFontBold size:18]];
[pickerItemLabel setTextAlignment:NSTextAlignmentCenter];
switch (pickerView.tag) {
case 0:
{
NSString* name = [alternateArrayFoBusinessNamesArray objectAtIndex:row];
[pickerItemLabel setText:[alternateArrayFoBusinessNamesArray objectAtIndex:row]];
}
break;
case 1:
[pickerItemLabel setText:[citiesNamesArray objectAtIndex:row]];
break;
case 2:
if ([[businessTypesArray objectAtIndex:0]isKindOfClass:[NSDictionary class]])
[pickerItemLabel setText:[businessTypesArray objectAtIndex:row]];
else
[pickerItemLabel setText:[businessTypesArray objectAtIndex:row]];
break;
case 3:
[pickerItemLabel setText:[postalCodesArray objectAtIndex:row]];
break;
}
return pickerItemLabel;
}
你將不得不提供一些代碼,以便使社會幫助您,請提供選擇器視圖的實施。 –
請添加您使用的代碼 –
您的實施將會有所幫助。 –