UITextfield代表未被解雇

时间:2015-08-06 16:40:04

标签: ios objective-c uitableview uitextfielddelegate

我在UITableView的单元格中有一系列文本字段。我已成功实现了可折叠表视图。但不知怎的,像-(void)textFieldDidBeginEditing这样的文本域代表没有被调用。我已经发布了以下代码。

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *myCell;

    if ([indexPath section]==1 && arrBlockFriendsName.count>0)
    {
        static NSString *identifier=@"BlockCell";
        BlockUsersTableViewCell *cell=(BlockUsersTableViewCell*)[tableView dequeueReusableCellWithIdentifier:identifier];

        if (cell==nil)
        {
            cell=[[[NSBundle mainBundle]loadNibNamed:@"BlockUsersTableViewCell" owner:self options:nil]objectAtIndex:0];
        }

        cell.imgBlockFriend.image=[UIImage imageNamed:[arrBlockFriendsImage objectAtIndex:indexPath.row]];
        cell.imgBlockIcon.image=[UIImage imageNamed:@"user_lock_icon1.png"];
        cell.lblBlockFriendName.text=[arrBlockFriendsName objectAtIndex:indexPath.row];
        cell.lblBlockFriendPlace.text=[arrBlockFriendsPlace objectAtIndex:indexPath.row];

        myCell=cell;
    }

    if ([indexPath section]==3)
    {
        AgeSliderTableCell *cell=(AgeSliderTableCell*)[tableView dequeueReusableCellWithIdentifier:@"AgeCell"];
        //cell.delegate=self;

        if (cell==nil)
        {
            cell=[[[NSBundle mainBundle]loadNibNamed:@"AgeSliderTableCell" owner:self options:nil]objectAtIndex:0];
        }

        [cell.labelSlider setUpperValue:ageUpperValue];
        [cell.labelSlider setMinimumValue:18];
        [cell.labelSlider addTarget:self action:@selector(updateSliderLabels:) forControlEvents:UIControlEventValueChanged];

        myCell=cell;
    }

    if ([indexPath section]==4 && arrLocationLabel.count>0)
    {
        static NSString *identifierLocation=@"LocationCell";

        LocationTableViewCell *cell=nil;

        if (indexPath.row ==3)
        {
            cell=[tableView dequeueReusableCellWithIdentifier:identifierLocation];

            cell=[[[NSBundle mainBundle]loadNibNamed:@"LocationTableViewCell" owner:self options:nil]objectAtIndex:1];


            [cell.btnSave addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
        }

        if( indexPath.row==0 || indexPath.row==1 || indexPath.row==2)
        {
            cell=[tableView dequeueReusableCellWithIdentifier:identifierLocation];

            cell=[[[NSBundle mainBundle]loadNibNamed:@"LocationTableViewCell" owner:self options:nil]objectAtIndex:0];

            cell.lblLocationDetails.text=[arrLocationLabel objectAtIndex:indexPath.row];
            cell.txtLocationDetails.delegate=self;

        }
               myCell=cell;
    }
    myCell.selectionStyle=UITableViewCellSelectionStyleNone;
    return myCell;
}

任何可能缺少的想法?

1 个答案:

答案 0 :(得分:0)

从您的代码中,您似乎只为cell.txtLocationDetailscell.lblBlockFriendName设置了cell.lblBlockFriendPlace文本字段的委托,而 。您可能希望对它们执行与cell.txtLocationDetails相同的操作。