二、监听UIAlertView。
1、在上面的代码基础上,在addbuttonViewController.h文件添加委托
- #import <UIKit/UIKit.h>
- @interface addbuttonViewController : UIViewController<UIAlertViewDelegate>
- - (IBAction)addButton:(id)sender;
- @end
2、在AlertView中多添加两个按钮
- -(void) someButtonClicked{
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
- message:@"您点击了动态按钮!"
- delegate:self
- cancelButtonTitle:@"确定"
- otherButtonTitles:@"取消",@"第三项",nil];
- [alert show];
- }
效果图:

