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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

AppleWatch开发-AlertController

發布時間:2024/9/30 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AppleWatch开发-AlertController 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

AlertController

前言

  • AlertController控件效果

  • (1)Alert樣式

  • (2)SideBySideButtonsAlert樣式

  • (3)ActionSheet樣式

1.1-簡介

  • 彈出一個AlertController控件是Watch OS2.0中新增的方法

  • AlertController類似于iPhone中的ActionSheet控件和AlertView控件

  • 不同的是Alert與ActionSheet只是AlertController的一種style

    • WatchOS2.0是把AlertView和ActionSheet集成到AlertController中

1.2-API

  • 非常簡單的一個方法,直接集成在WKInterfaceController中

1.3-示例

/*創建按鈕點擊對應的action第一個參數:標題第二個參數:stylecase Deault 默認樣式case Cancel 在左上角顯示case Destructive 紅色顯示第三個參數:點擊回調*/let action1 = WKAlertAction(title: "按鈕1", style: WKAlertActionStyle.Cancel) { () -> Void inprint("點擊按鈕1")}let action2 = WKAlertAction(title: "按鈕2", style: WKAlertActionStyle.Destructive) { () -> Void inprint("點擊按鈕2")}let action3 = WKAlertAction(title: "按鈕3", style: WKAlertActionStyle.Default) { () -> Void inprint("點擊按鈕3")}/*第一個參數:標題第二個參數:信息第三個參數:stylecase Alert 備注:一定要一個或以上的action 否則報錯requires one or more actions case SideBySideButtonsAlert 備注:一定只能是兩個action 否則報錯exactly two actions are needed for WKAlertControllerStyleSideBySideButtonsAlertcase ActionSheet第四個參數:按鈕點擊對應的方法actions*/presentAlertControllerWithTitle("title", message: "message", preferredStyle: WKAlertControllerStyle.ActionSheet, actions: [action1,action2,action3])

1.4-注意事項

  • Alert樣式和ActionSheet樣式的唯一區別是Alert樣式左上角沒有Cancel按鈕,而ActionSheet樣式左上角有Cancel按鈕用于取消選擇

  • Alert樣式不支持AlertAction的Cancel樣式,而ActionSheet樣式支持

總結

以上是生活随笔為你收集整理的AppleWatch开发-AlertController的全部內容,希望文章能夠幫你解決所遇到的問題。

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