- (IBAction)buttonClick:(id)sender
{
UIButton *button = (UIButton *)sender; // 意思就是把sender强转为UIButton,因为这里点击事件对象就是UIButton NSString *title = [NSString stringWithFormat:@"Button tag %d",button.tag]; // button.tag 就是在IB中设置的数字,每个按钮不一样。 NSString *message = [button currentTitle]; //currentTitle 表示当前的按钮上面的文本信息 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil]; [alert show]; }