- (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;
}
希望这能消除您的疑问。
关于ios - 如何将值从选择器设置为特定部分的自定义单元格文本字段?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44368485/