コードまたは Interface Builder で、各ボタンに一意のタグを付けます。
次に、アクションで次のことができます。
- (IBAction)openAction:(id)sender {
UIButton *b = (UIButton *)sender;
NSLog(@"button %d is pressed", b.tag);
}
すでに imageviews タグを付けているようです。それらはボタンではありません!代わりに、コンテンツが画像の UIButton を作成する必要があります。UIButton の setImage:forState: を参照してください。
編集:以下の質問への回答として、以下に例を示します。
NSMutableArray *bArray = [NSMutableArray arrayWithCapacity:kNumImages];
NSUInteger i;
for (i = 1; i <= kNumImages; i++)
{
NSString *imageName = [NSString stringWithFormat:@"image%d.jpg", i];
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
btn setImage:imageName forState:UIControlStateNormal];
btn.tag = 100+i;
[bArray addObject:btn];
}