Domanda

i am creating a button using the following code:

[self addCenterButtonWithImage:[UIImage imageNamed:@"scan.png"]
 highlightImage:[UIImage imageNamed:@"scan_hover.png"]];

i need to connect this to a method. how do i do that? i am very new to ios development, so sorry if this is a stupid question.

would it be possible to load a view controller on clicking the button?( i have the code to be executed in the viewdidload method) basically this button is there to customise the tab bar to have the centre tab item jutting out...

È stato utile?

Soluzione

You can connect to a IBAction in interface builder

-(IBAction)someMethod:(id)sender{
}

You can connect programatically

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(someMethod:) forControlEvents:UIControlEventTouchUpInside];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top