views:

23

answers:

2

i am having table view which is present when i press a button and when i select any of the rows of table view i want to change button text with that content of cell text in table view... so i want to pass description which is string to the called function and i have to recieve it in main view where i have to change button text with this....

i am new to iphone so any body help me to do this

A: 

Make an outlet for the button and connect it.

in the .h, between the curly braces

 UIButton* button;

after the curly

 @property(retain, nonatomic) IBOutlet UIButton* button;

and in the .m, after the @implementation

@synthesize button;

Then connect in IB by dragging a referencing outlet circle in the connections inspector to File's Owner and choosing button.

Now you can change the button text with

 [self.button setTitle: @"hello" forState: UIControlStateNormal]; // or any string, like from your table
Lou Franco
A: 

You can do like this:

You have to pass the button to the UITableViewController and then when you select a row, set the text for the button:

UITableViewController *viewController = [[CustomTableViewController alloc] initWithButton:self.button];

then in tableView:didSelectRowAtIndexPath:

[self.button setTitle:cell.textLabel.text forState:UIControlStateNormal];

Don't forget to save the button in your init with:

-(id)initWithButton:(UIButton *)button {
  // do something
  _button = button
}
vodkhang