Я создал массив кнопок, но я не вижу, чтобы кнопки обрабатывали события касания (buttonEvent: не звонки)
Это мой код - это не правильно?
- (void)loadView{
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:screenRect];
[backgroundImageView setImage:[UIImage imageNamed:@"background.png"]];
backgroundImageView.opaque = YES;
self.view = backgroundImageView;
[backgroundImageView release];
CGRect brandRect = CGRectMake(90, 25, 140, 70);
UIImageView *brandImageView = [[UIImageView alloc] initWithFrame:brandRect];
[brandImageView setImage:[UIImage imageNamed:@"brand.png"]];
[self.view addSubview:brandImageView];
buttons = [NSMutableArray array];
int y = 100;
for ( int i = 0 ; i < 5; i++ ){
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(20, y, 280, 50)];
if ( i == 0 ){
[button setBackgroundImage:[UIImage imageNamed:@"select_active.png"] forState:UIControlStateNormal];
} else {
[button setBackgroundImage:[UIImage imageNamed:@"select_passive.png"] forState:UIControlStateNormal];
}
[button setTitle:[NSString stringWithFormat:@"Object%d",i] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonEvent:) forControlEvents:UIControlEventAllEvents];
button.tag = 1000 + i ;
[self.view addSubview:button];
y += 60;
}
-(void)buttonEvent:(id)sender {
NSLog(@"new button clicked!!!");
}