Q: How to add event on click of a button in uitableviewcell in xcode I want to create a click event on the button, 
This event should take text for a corresponding textfield and print is as a label for a previous cell.
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

 static NSString *cellidentifier=@"cellidentifier";


 UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellidentifier];

if(cell==nil)
{ 
    cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault                                                          reuseIdentifier:cellidentifier]autorelease];

 }

if((indexPath.row%2)==0)
{
    UILabel* lblnames=[[UILabel alloc]initWithFrame:CGRectMake(5,5 ,170 ,25)];
    [lblnames setText:[listoffriends objectAtIndex:indexPath.row]];
    [lblnames setTag:indexPath.row];
    cell.contentView.backgroundColor=[UIColor purpleColor];
    [cell.contentView addSubview:lblnames]; 
}     
else
{     
    UITextField*  txtn=[[UITextField alloc]initWithFrame:CGRectMake(5, 5, 150, 25)];        
    txtn.delegate=self;
    [txtn setTag:indexPath.row];
    UIButton*btnclkd=[[UIButton buttonWithType:UIButtonTypeRoundedRect]retain];
    btnclkd.frame=CGRectMake(200, 5, 70, 25);
    [btnclkd setTag:indexPath.row];
    [btnclkd setTitle:@"OK" forState:UIControlStateNormal] ;
    [btnclkd addTarget:self action:@selector(btnok:)forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:btnclkd];
    cell.contentView.backgroundColor=[UIColor lightGrayColor];
    [cell.contentView addSubview:txtn];   
}
return  cell; 
}


-(void)btnok:(id)sender
{ 
int tag=([sender tag]);
NSLog(@"%d",tag);
}    


A: This is probably what you want to call :  
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths 
              withRowAnimation:(UITableViewRowAnimation)animation  

On UITableView you need to ask a row, section or the whole table to reload so modification can be reflected on the screen.
