Ios 如何将值从选择器设置为特定节的自定义单元格文本字段?
我希望这能消除您的疑虑。它可以工作,但…我想在picker的did select row方法中使用自定义单元格变量设置textfield的值。先生,实际上我想设置自定义单元格textfield的值,所以我不知道如何在picker method DIDSELECTROW中设置值…请参阅上文…提前感谢。。。Ios 如何将值从选择器设置为特定节的自定义单元格文本字段?,ios,objective-c,Ios,Objective C,我希望这能消除您的疑虑。它可以工作,但…我想在picker的did select row方法中使用自定义单元格变量设置textfield的值。先生,实际上我想设置自定义单元格textfield的值,所以我不知道如何在picker method DIDSELECTROW中设置值…请参阅上文…提前感谢。。。 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)inde
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section==0)
{
if(indexPath.row==1)
{
static NSString *CellIdentifier = @"custom1TableViewCell";
custom1TableViewCell *cell2 = (custom1TableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell2 == nil)
{
cell2 = [[ custom1TableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *dictionary = [dataArray objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"data"];
cell2.language.text = [array objectAtIndex:indexPath.row];
//for picker
[cell2.sellanguage setInputView:pickerview];
cell2.sellanguage.text = selectedLanguage;
return cell2;
}
static NSString *CellIdentifier = @"customTableViewCell";
customTableViewCell *cell = (customTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[customTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *dictionary = [dataArray objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"data"];
cell.soundfx.text = [array objectAtIndex:indexPath.row];
return cell;
}
- (void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
[pickerview selectRow:row inComponent:0 animated:YES];
NSLog(@"%@",[languages objectAtIndex:row]);
selectedLanguage= [languages objectAtIndex:row];
[[self view] endEditing:YES];
[self.tableview reloadData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// now you can use cell.textLabel.text
//For Example
self.textfield.text = cell.textLabel.text;
}