日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

IOS9+基础之警报框弹出和操作表弹出

發布時間:2023/12/18 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 IOS9+基础之警报框弹出和操作表弹出 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

IOS9+基礎之警報框彈出和操作表彈出


代碼如下

// // ViewController.m // 001-UIAlertView // // Created by lujun on 2021/6/3. //#import "ViewController.h"@interface ViewController () - (IBAction)rightClick:(id)sender;@end@implementation ViewController- (IBAction)clck2:(id)sender {// UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"標題" message:@"消息" delegate:self cancelButtonTitle:@"取消按鈕" otherButtonTitles:@"其他按鈕標題", nil]; // // [alert show];//1.創建UIAlertControlerUIAlertController *alert = [UIAlertController alertControllerWithTitle:@"標題" message:@"這是一些信息" preferredStyle:UIAlertControllerStyleAlert];/*參數說明:Title:彈框的標題message:彈框的消息內容preferredStyle:彈框樣式:UIAlertControllerStyleAlert*///2.添加按鈕動作//2.1 確認按鈕UIAlertAction *conform = [UIAlertAction actionWithTitle:@"確認" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了確認按鈕");}];//2.2 取消按鈕UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了取消按鈕");}];//2.3 還可以添加文本框 通過 alert.textFields.firstObject 獲得該文本框 // [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { // textField.placeholder = @"請填寫您的反饋信息"; // }];//3.將動作按鈕 添加到控制器中[alert addAction:conform];[alert addAction:cancel];//4.顯示彈框[self presentViewController:alert animated:YES completion:nil];}- (IBAction)leftClick:(id)sender {// UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"標題" message:@"消息" delegate:self cancelButtonTitle:@"取消按鈕" otherButtonTitles:@"其他按鈕標題", nil]; // // [alert show];//1.創建UIAlertControlerUIAlertController *alert = [UIAlertController alertControllerWithTitle:@"標題" message:@"這是一些信息" preferredStyle:UIAlertControllerStyleAlert];/*參數說明:Title:彈框的標題message:彈框的消息內容preferredStyle:彈框樣式:UIAlertControllerStyleAlert*///2.添加按鈕動作//2.1 確認按鈕UIAlertAction *conform = [UIAlertAction actionWithTitle:@"確認" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了確認按鈕");}];//2.2 取消按鈕UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了取消按鈕");}];//2.3 還可以添加文本框 通過 alert.textFields.firstObject 獲得該文本框[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {textField.placeholder = @"請填寫您的反饋信息";}];//3.將動作按鈕 添加到控制器中[alert addAction:conform];[alert addAction:cancel];//4.顯示彈框[self presentViewController:alert animated:YES completion:nil];}- (void)viewDidLoad {[super viewDidLoad];}- (IBAction)rightClick:(id)sender {//1.創建ControllerUIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:@"標題" message:@"一些信息" preferredStyle:UIAlertControllerStyleActionSheet];/*參數說明:Title:彈框的標題message:彈框的消息內容preferredStyle:彈框樣式:UIAlertControllerStyleActionSheet*///2.添加按鈕動作UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"項目1" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了項目1");}];UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"項目2" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了項目2");}];UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {NSLog(@"點擊了取消");}];//3.添加動作[alertSheet addAction:action1];[alertSheet addAction:action2];[alertSheet addAction:cancel];//4.顯示sheet[self presentViewController:alertSheet animated:YES completion:nil];} @end

總結

以上是生活随笔為你收集整理的IOS9+基础之警报框弹出和操作表弹出的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。