我有一个 UIButton 以编程方式添加到 tableview 中。问题是,当它被触摸时,我遇到了发送到实例错误消息的无法识别的选择器。
UIButton *alertButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
[alertButton addTarget:self.tableView action:@selector(showAlert:)
forControlEvents:UIControlEventTouchUpInside];
alertButton.frame = CGRectMake(220.0, 20.0, 160.0, 40.0);
[self.tableView addSubview:alertButton];
这是我想在触摸 InfoDark UIButton 时触发的警报方法:
- (void) showAlert {
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"My App"
message: @"Welcome to ******. \n\nSome Message........"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
[alert release];
}
谢谢你的帮助。