• <noscript id="e0iig"><kbd id="e0iig"></kbd></noscript>
  • <td id="e0iig"></td>
  • <option id="e0iig"></option>
  • <noscript id="e0iig"><source id="e0iig"></source></noscript>
  • UIKit 框架之UIAlertController

    IOS8之后增加了UIAlertController類,它可以表示UIAlertView和UIActionSheet.它繼承自UIViewController。


    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window.backgroundColor=[UIColor whiteColor];
        [self.window makeKeyAndVisible];
         
        ViewController *vc=[[ViewController alloc]init];
        UINavigationController *nvc=[[UINavigationController alloc]initWithRootViewController:vc];
        self.window.rootViewController=nvc;
        return YES;
    }


    //
    //  ViewController.m
    //  AlertVC
    //
    //  Created by City--Online on 15/5/25.
    //  Copyright (c) 2015年 XQB. All rights reserved.
    //
     
    #import "ViewController.h"
     
    @interface ViewController ()
     
    @end
     
    @implementation ViewController
     
    - (void)viewDidLoad {
        [super viewDidLoad];
        UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame=CGRectMake(100, 100, 50, 50);
        [btn setTitle:@"按鈕" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        btn.layer.borderWidth=2.0;
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
         
         
         
         
    } 
    -(void)btnClick:(id)sender
    {
    //    UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
    //    
    //    [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    //        textField.text=@"name";
    //        textField.clearsOnBeginEditing=YES;
    //    }];
    //    [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    //        textField.text=@"password";
    //        textField.clearsOnBeginEditing=YES;
    //    }];
         
        UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleActionSheet];
         
        UIAlertAction *actionOk=[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            NSLog(@"確定");
        }];
        UIAlertAction *actionCancel=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
            NSLog(@"取消");
        }];
        [alert addAction:actionOk];
        [alert addAction:actionCancel];
        [self presentViewController:alert animated:YES completion:nil];
    }
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
     
    @end

     



    版權聲明:本文為weixin_34399060原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
    本文鏈接:https://blog.csdn.net/weixin_34399060/article/details/90660792

    智能推薦

    Swift — UIKit 之(5)—— TableViews

    文章目錄 0. 本篇重點 1. Table Views 2. 新建工程Tabbed App 3. 準備主界面 3.1 刪除 Second View 3.2 添加一個 TableViewController,并關聯到 TabBar 3.3 再加一個 TableViewController,并關聯到 TabBar,命名為“自定義Cell” 4. 第一個頁面“初步&r...

    SwiftUI封裝UIKit之UIDatePicker

    本文價值與收獲 看完本文后,您將能夠作出下面的界面 [email protected] 看完本文您將掌握的技能 UIDatePicker基礎使用 掌握SwiftUI使用UIDatePicker方法 代碼 推薦 基礎文章推薦 《SwiftUI是什么,聽聽大牛們如何說》 經典教程推薦 onevcat 大神的《SwiftUI 與 Combine 編程》 更新近百篇SwiftUI教程《...

    UIKit框架(8)屏幕適配(二)

    AutoLayout介紹 AutoLayout的功能要比AutoResizing強大的多。      當對一個UIView對象使用了AutoLayout布局后,意味著放棄了通過對象的frame進行修改視圖的位置、尺寸。      AutoLayout使約束條件,通過自動布局引擎,計算view對象的f...

    Swift — UIKit 之(4)—— TabBar|ToolBar|NavigationBar

    文章目錄 0. 本篇主要內容 1. TabBar [0] 長啥樣 [1] 建立項目 [2] 添加一個 TabBarController [3] 添加一個 NavigationController 2. ToolBar [4] 在TabBar的第一個界面(櫻桃)添加一個ToolBar [5] 在ToolBar下面添加一個View并拉滿 [6] 為該界面綁定一個控制類 [7] 綁定事件 [8] 編寫代...

    UIKit框架(11)導航控制器UINavigationController

    介紹多控制器管理中非常重要的一個控制器UINavigationController 它負責管理多個控制器,能夠輕松完成控制器間的切換 如:iOS系統上的設置      父類是UIViewController,但其功能并非是管理view,而是管理多個控制器 控制器棧式管理:       當切換時,將一個控制器入棧,當返回...

    猜你喜歡

    UIKit框架-自定義視圖-分段控制器

    自定義分段控制器 實現簡單點擊事件 效果圖 1.創建工程、創建UIView子類YYJTopView; 2.YYJTopView.h文件聲明一個數組用于接受內容; 3.YYJTopView.m文件實現數組seter方法,常見標題按鈕 4.實現按鈕點擊方法 這里按鈕的狀態不用UIControlStateSelected而用UIControlStateDisabled,是因為當按鈕處于selected狀...

    uikit框架開發前期配置及定制主題方法。

    要使用npm命令需要先安裝nodejs。 安裝方法網上有很多,在此就不一一例舉了。 1. 安裝Gulp 首先需要在全局范圍安裝gulp 用git下載Uikit。 這需要安裝git,進http://github.com/uikit/uikit直接下載后解壓就可以。 下載之后會自動生成uikit文件夾。 而后進入uikit目錄 2. 安裝node依賴的模塊。 執行npm install安裝node依賴...

    Swift — UIKit 之(1)—— 基本組件總覽

    參考資料:Apple官方KeyNote文件 文章目錄 1. 常見的系統視圖 2. 標簽(UILabel) 3. 圖像視圖(UIImageView) 4. 文本視圖(UITextView) 5. 滾動視圖(UIScrollView) 6. 表格視圖(UITableView) 7. 工具欄(UIToolBar) 8. 導航欄(UINavigationBar) 9. 標簽欄(UITabBarContro...

    Swift — UIKit 之(6)—— Model 的 CRUD(文件版)

    文章目錄 0. 本篇重點 1. 項目整體框架 1.1 新建一個 Single View App 1.2 在 Main.storyboard 中添加一個 Navigation Controller 1.3 更改根界面 1.4 給詳細頁面的 ViewController 更名(第三個界面,最右邊) 1.5 為“列表”界面添加 UIViewTableController 并關聯 ...

    HTML中常用操作關于:頁面跳轉,空格

    1.頁面跳轉 2.空格的代替符...

    精品国产乱码久久久久久蜜桃不卡