Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming your view controller with the buttons is in a navigation controller - presumably at the root...</p> <p>What you would do is, add a target to each of your buttons, in code this can be done with the method <code>addTarget:action:forControlEvents:</code> of your <code>UIButton</code></p> <p>For example:</p> <pre><code>[myBtn addTarget:self action:@selector(tappedButton:) forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>The method tappedButton will be messaged with the button that was tapped:</p> <pre><code>- (void)tappedButton:(UIButton*)sender{ // exploit the button } </code></pre> <p>Inside this method you can get the title of the button - <code>myBtn.titleLabel.text</code></p> <p>You can then create a new view controller (let's keep things simple and say you have your own <code>UIViewController</code> subclass called <code>MySimpleViewController</code>. </p> <p>In this class you have a <code>cameFrom</code> property which you can set the button's title on, and in <code>viewDidLoad</code> of <code>MySimpleViewController</code>, you would get the property value of <code>cameFrom</code>, this could be the method implementation.</p> <pre><code>- (void)tappedButton:(UIButton*)sender{ MySimpleViewController *detail = [[MySimpleViewController alloc] init]; detail.cameFrom = sender.titleLabel.text; [self.navigationController pushViewController:detail animated:YES]; [detail release]; } </code></pre> <p>So over in your <code>MySimpleViewController's</code> <code>viewDidLoad</code>, you create a <code>UILabel</code>, give the text property the value of <code>self.cameFrom</code> and add it to the view with <code>addSubview:</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload