Hey guys I need to create several buttons in a app so I made this function:
- (UIButton*) SetButton:(UIButton*)boton withTag:(int)Tag andFrame:(CGRect)Frame
{
NSArray *aux = [[NSArray alloc]init];
boton = [[UIButton buttonWithType:UIButtonTypeRoundedRect]retain];
boton.frame = Frame;
boton.tag = Tag;
aux = [[AmericaInfo objectAtIndex:Tag] componentsSeparatedByString:@" "];
[boton setTitle: [aux objectAtIndex:KIndex] forState:0];
boton.titleLabel.font = [UIFont fontWithName:@"Arial" size:14];
boton.titleLabel.textColor = [UIColor blackColor];
[boton addTarget:self action:@selector(HoldAmericaBoton:) forControlEvents:UIControlEventTouchDown];
[boton addTarget:self action:@selector(TapAmericaBoton:) forControlEvents:UIControlEventTouchUpInside];
[aux release];
return boton;
}
Then If need to create a button I do this:
UIButton *a0 = [self SetButton:a0 withTag:0 andFrame:CGRectMake(1450, 200, 72, 37)];
It is not working... The code is wrong? or should I make function like initWith that returns an id?
Thanks Carlos Vargas