iOS之提示框的道道

来源:互联网 发布:淘宝新店查询软件 编辑:程序博客网 时间:2024/04/28 21:59

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    //创建提示框控制器选择样式决定出现在中间还是下面

    UIAlertController *alertVC = [UIAlertControlleralertControllerWithTitle:@"你说什么"message:nilpreferredStyle:UIAlertControllerStyleAlert];

    //创建提示按钮

    UIAlertAction *actiona = [UIAlertActionactionWithTitle:@"我说你傻"style:UIAlertActionStyleCancelhandler:nil];

    //把提示按钮添加到控制器里

    [alertVC addAction:actiona];

  //给提示框加入键盘输入框

//显示在底部 不支持输入框

    [alertVC addTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) {

        [textField addTarget:selfaction:@selector(ffff:)forControlEvents:UIControlEventEditingChanged];

       

    }];

    //控制器跳转方法  present对应dismiss

      [selfpresentViewController:alertVCanimated:YEScompletion:nil];

    

}

//键盘响应方法

-(void)ffff:(UITextField *)sender{

    NSLog(@"%@",sender.text);

}



0 0
原创粉丝点击