对话框UIAlertView

来源:互联网 发布:剑三冷艳毒姐捏脸数据 编辑:程序博客网 时间:2024/06/10 13:09
对话框学习UIAlertView当一个control中有多个alertdialog的时候,绑定alertdialog的tag来区分不同的alertdialog#import "ViewController.h"@interface ViewController () <UIAlertViewDelegate>- (IBAction)showAlertDialog;- (IBAction)showActionSheet;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];}- (IBAction)showAlertDialog{    /**     *  对话款展示     */    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"普通对话框标题" message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];    [alert show];}- (IBAction)showActionSheet{    /**      弹出警告对话框      cancelButtonTitle取消按钮始终在最下面      destructiveButtonTitle 比较危险的操作都用这个按钮,比如按钮 :  “是”  吗?     */    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"标题栏" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"cancel discriptio" otherButtonTitles:@"sure", nil];    [sheet showInView:self.view];}- (IBAction)showActionSheet:(id)sender {}/** *  点击按钮的监听器,判断用户点击了哪个按钮 */- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    switch (buttonIndex) {        case 0:            NSLog(@"00000");            break;                    case 1:            NSLog(@"1111");            break;                    default:            break;    }}@end继续补充    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"数据展示" message:message delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];    alert.alertViewStyle = UIAlertViewStylePlainTextInput;    UIAlertView补强:1、自身带有可用的输入框,不用自己在addsubview2、这里学习一个自学的方法,既然有一个文本输入框,那肯定有获取输入框的方法,通过UITextField就能找到对应的方法,这是自学能力3、通过索引获取输入框:UITextField *textField = [alert textFieldAtIndex:0]4、确定,取消按钮监听通过代理:#pragma mark - alertview代理- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{   }

0 0
原创粉丝点击