1

そのボタンをクリックすると、ボタンアクションでそのボタンのタイトルが表示されるはずです。

if (tableView==groupTableView) {
        GroupData*theData=[groupArray objectAtIndex:indexPath.row];
        cell.textLabel.font=[UIFont fontWithName:@"Helvetica" size:16];
        cell.textLabel.text=theData.GroupTitle;

        addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        //[tab1 setFrame:CGRectMake(-1,2,293,58)];

        addButton.Frame=CGRectMake(400,2,42,42);

        [addButton setTitle:@"Record Video" forState:UIControlStateNormal];
        [addButton addTarget:self action:@selector(tab1Action) forControlEvents:UIControlEventTouchUpInside];
        [addButton setImage:[UIImage imageNamed:@"popuptab1j.png"] forState:UIControlStateNormal];

        addButton.clipsToBounds=YES;           
        [cell addSubview:addButton];

        return cell;     
}

-(void)tab1Action {    
     NSLog(@"Cell Tab1 Clicked %@",clicked);
}

この追加ボタンをクリックすると、選択したボタンの groupTitle が表示され、ボタンがクリックされたセルのグループタイトルが表示されます。

4

1 に答える 1

0

次のようなタグを使用して UITableViewCell にボタンを設定します:-

    addButton = [UIButton buttonWithType:UIButtonTypeCustom];
    addButton.Frame=CGRectMake(400,2,42,42);

    [addButton setTitle:@"Record Video" forState:UIControlStateNormal];
    [addButton addTarget:self action:@selector(tab1Action:) forControlEvents:UIControlEventTouchUpInside];
    addButton.tag=indexPath.row;
    [addButton setImage:[UIImage imageNamed:@"popuptab1j.png"] forState:UIControlStateNormal];
    addButton.clipsToBounds=YES;
    [[cell contentView] addSubview:addButton];



    -(IBAction)tab1Action:(UIButton *)sender
    { 
        NSLog(@"=== >  %d",sender.tag);
    //apple your Logic
    }

注:-使用する [[cell contentView] addSubview:addButton];代わりに使用 [cell addSubview:addButton];し、iPhone 400 の適切なボタン フレームを設定していないか、画面幅を設定していません。

于 2013-07-17T06:42:39.627 に答える