How can I bind a function to my button that I created this way
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
[button addTarget:self
action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown]
button.frame = CGRectMake(80.0, 160.0, 160.0, 40.0);
[button setTitle:string forState:UIControlStateNormal]
[self.view addSubview:button]
I want to do the same thing as IB when I associate a function with a button. Is it possible?
Csabi source
share