How To Trigger A Button's Action Programmatically

Discussion in 'iPhone/iPad Programming' started by loon3y, Mar 7, 2012.

  1. macrumors 65816

    loon3y

    Joined:
    Oct 21, 2011
    #1
    how can a program a button so it triggers another buttons actions?
     
  2. macrumors 6502a

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    Just call the other button's IBAction function.
     
  3. macrumors 6502

    Joined:
    Apr 9, 2011
    Location:
    Bismarck, North Dakota
    #3
    Just link the IBActions from the other buttons to that button.
     
  4. macrumors member

    vultureboy

    Joined:
    Nov 28, 2006
    Location:
    Blackpool, UK
    #4
    As people have mentioned previously you can just link it to that action in interface builder.

    If you wished to do something else on the second button Before calling the first buttons actions then link the button 2 to it's own action and then call the first buttons method like...

    Code:
    - (IBAction) button2Touch:(id)sender
    {
        NSLog(@"Do Something Else Now");
        [self button1Touch:sender];
    }
    
     

Share This Page