开发者

i want to pass a value returned by method in one view to called function which is present in another view

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 th开发者_运维百科at 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


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


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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜