Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hey Guys, please let me know how can I set this code action in to an UIButton action... Here is the code:

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

NSString *myIdentiFier=@"myIdentiFier";

myCell *cell=[tableView dequeueReusableCellWithIdentifier:myIdentiFier];

if(!cell){
    //cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myIdentiFier];
    NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"myCell" owner:self options:nil];
    for(id obj in nib){
        if([obj isKindOfClass:[myCell class]]){
            cell=(myCell *)obj;
            break;
        }
    }
}

NSDictionary *diction=(NSDictionary*)[content objectAtIndex:indexPath.row];
[cell.contentView setBackgroundColor:[UIColor orangeColor]];

cell.empID.text=[diction objectForKey:@"empid"];
cell.empName.text=[diction objectForKey:@"empname"];
cell.designation.text=[diction objectForKey:@"empdesignation"];
cell.teamName.text=[diction objectForKey:@"empteam"];

return  cell;

}

i want to set above action in my button..

- (IBAction)displayRecord:(id)sender {
}

please tell me ...

share|improve this question
    
what actually you are looking for –  Bhupesh May 30 '13 at 12:48
    
@Bhupesh whatever my tableview method is doing i want that it should done by button action.. –  Deep May 30 '13 at 12:50
    
Do you want to add new cell in the table view? For that you need to insert new entry in your data source i.e content array in your case. Once that is done, call [tableView reloadData]. –  Amar May 30 '13 at 12:52

2 Answers 2

you can call

[tableview reloadData]

than cellForRowAtIndexPath is called.

share|improve this answer
    
Please elaborate.. i din get –  Deep May 30 '13 at 12:53
    
look at this example: aboveground.com/tutorials/… –  Birdy May 30 '13 at 13:11

simply u can do as follow

- (IBAction)displayRecord:(id)sender {
           [yourTablename reloadData];
}
share|improve this answer
    
if any query plz ask –  Kanhaiya Sharma May 30 '13 at 12:54
    
check your tableView frame –  Kanhaiya Sharma May 30 '13 at 12:57
    
Not displaying.. data which displaying disappearing after click.. :( –  Deep May 30 '13 at 12:59
    
your tableView is show on not .tell me –  Kanhaiya Sharma May 30 '13 at 13:00
    
Uncomment this line cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myIdentiFier]; –  Kanhaiya Sharma May 30 '13 at 13:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.