我有以下代码,在 UIToolbar (postoInfo) 上添加一个类型 UIBarbutton 的按钮 :
UIImage *faceImage = [UIImage imageNamed:@"informazioni.png"];
UIButton *face = [UIButton buttonWithType:UIButtonTypeCustom];
[face addTarget:self action:@selector(press:) forControlEvents:UIControlEventTouchUpInside];
face.bounds = CGRectMake( 0, 0, 30, 30 );
[face setImage:faceImage forState:UIControlStateNormal];
buttonOne = [[UIBarButtonItem alloc] initWithCustomView:face];
NSArray *buttons = [NSArray arrayWithObjects: buttonOne, nil];
[postoInfo setItems: buttons animated:YES];
I would call a method when the button is pressed, I added, the following line, but does not work:
[face addTarget:self action:@selector(press:) forControlEvents:UIControlEventTouchUpInside];