tags:

views:

16

answers:

0
- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell=nil;
    static NSString *kCell=@"cell";
    if(indexPath.section==0){
        cell=[tableView1 dequeueReusableCellWithIdentifier:kCell];
    }
    if (cell==nil) {
        if(indexPath.section==0){
            cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kCell]autorelease];
            cell.selectionStyle=UITableViewCellSelectionStyleBlue;
            cell.accessoryType = UITableViewCellAccessoryNone;

            UILabel *setInfor3=[[UILabel alloc]initWithFrame:CGRectMake(200,20,80,30)];
            [setInfor3 setFont:[UIFont boldSystemFontOfSize:12]];
            [setInfor3 setTextAlignment:UITextAlignmentLeft];
            setInfor3.tag=1003;
            [setInfor3 setTextColor:[UIColor blackColor]];  
            [setInfor3 setBackgroundColor:[UIColor clearColor]];
            [cell.contentView addSubview:setInfor3];
            [setInfor3 release];

            UIButton *swbtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
            [swbtn setFrame:CGRectMake(200, 50, 50, 25)];
            [swbtn.titleLabel setFont:[UIFont boldSystemFontOfSize:12]];
            [swbtn setTitle:@"删除" forState:UIControlStateNormal];
            [swbtn addTarget:self action:@selector(del:) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:swbtn];
        }
    }   
    if(dataoftest){
        if(indexPath.section==0){
            UILabel *label1=(UILabel *)[cell.contentView viewWithTag:1000];
            [label1 setText:[[dataoftest objectAtIndex:indexPath.row] objectForKey:@"ffname"]];
            UILabel *label2=(UILabel *)[cell.contentView viewWithTag:1001];
            [label2 setText:[[dataoftest objectAtIndex:indexPath.row] objectForKey:@"ssname"]];
            UILabel *label3=(UILabel *)[cell.contentView viewWithTag:1002];
            [label3 setText:[[dataoftest objectAtIndex:indexPath.row] objectForKey:@"ttname"]];
            UILabel *label4=(UILabel *)[cell.contentView viewWithTag:1003];
            [label4 setText:[[dataoftest objectAtIndex:indexPath.row] objectForKey:@"ffjindu"]];
        }
    }
    return cell;
}
-(void)del:(id)sender{
    NSLog(@"%@",[swtable indexPathSelectedRow]);
}
///////////////////////

my tableviewcell is created by plist file,about 3 rows,I hope that when I press then UIbutton,It will delete the row where its at. but the above program ,when I press then button,its cant get the indexPathSelectedRow,its NULL. I`m a Newbie.