iphone - Multiple UIButtons 1 function -


basically need have several buttons in view. them call 1 function can keep track of 'state'.

how can tell button called function? there anyway text of sender?

in ios action methods, including ibaction methods, can have of following signatures (see "target-action in uikit"):

- (void)action - (void)action:(id)sender - (void)action:(id)sender forevent:(uievent *)event 

if use method signature accepts sender have access object triggered action. can access properties on calling object including title , tag. can compare sender pointers may have buttons determine button sender of particular event.

i favor comparing pointers because believe if (sender == self.nextpagebutton) easier understand , less break if (sender.tag == 4) or if ([((uibutton *)sender).currenttitle isequaltostring:@"foo"]). looking @ tags in ib tells nothing code assumes mean , if or not important. titles change update ui or localize app , changes should not require code changes well.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -