objective c - Two buttons, one click -
i have 2 buttons on top of each other in nib. need both of them pressed when tapped, top button carries out function. there way top button tell bottom button activate when top 1 gets pressed. not think can merge buttons 1 , use 1 -(ibaction)buttonname function because 1 button bigger other not need both activate when 1 of them pressed.
thanks!
is there way top button tell bottom button activate when top 1 gets pressed.
not really, can have action top button call action bottom button.
here's 1 way:
- (ibaction)actiontop:(id)sender { nslog(@"the top button activated."); [self actionbottom:self]; } - (ibaction)actionbottom:(id)sender { nslog(@"the bottom button activated."); }
another way use same action both, , figure out based on button triggered action:
- (ibaction)action:(id)sender { // if top button tapped, part if (sender == self.topbutton) { nslog(@"the top button activated."); } // want bottom button activated no matter button tapped, // no need check here... nslog(@"the bottom button activated."); }
the bottom button whole screen changes displayed. top button plays sound, except there 4 top buttons plays different sounds
it seems invisible button covering whole screen might wrong way tackle problem. might using gesture recognizer attached view trigger change. button actions call same method gesture recognizer uses.
Comments
Post a Comment