ios - 如何将选择器中的值设置为特定部分的自定义单元格文本字段?

标签 ios objective-c

- (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/

相关文章:

ios - 具有核心数据的模型 Controller 抽象

objective-c - 无法在 TableView 中使用 pushViewController 打开详细 View 屏幕

Objective-C : Why is my retain count not 1?

iphone - 如果一个 UIButton alpha 设置为 0,不需要 removeFromSuperview 吗?

ios - pushviewcontroller 不起作用?

ios - Swift - UIDatePicker 限制选择天数

ios - 获取格式为 UTC+5 :30 的时区

objective-c - TextField 将不会在 Cocoa 应用程序中更新

iphone - UITableViewCell 和 UITableView 重复选择其他单元格?

ios - Xcode:无法加载配置文件。配置文件缺少所需的 UUID 属性