中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

做家具的企業(yè)網(wǎng)站最吸引人的營銷廣告詞

做家具的企業(yè)網(wǎng)站,最吸引人的營銷廣告詞,移動網(wǎng)站建設(shè)是什么意思,長春市長春網(wǎng)站建設(shè)哪家好目錄 前言關(guān)于UIAlertController具體操作及代碼實現(xiàn)總結(jié) 前言 在UI的警告對話框的學習中,我們發(fā)現(xiàn)UIAlertView在iOS 9中已經(jīng)被廢棄,我們找到UIAlertController來代替UIAlertView實現(xiàn)彈出框的功能,從而有了這篇關(guān)于UIAlertController的學習筆記…

目錄

  • 前言
  • 關(guān)于UIAlertController
  • 具體操作及代碼實現(xiàn)
  • 總結(jié)

前言

??在UI的警告對話框的學習中,我們發(fā)現(xiàn)UIAlertView在iOS 9中已經(jīng)被廢棄,我們找到UIAlertController來代替UIAlertView實現(xiàn)彈出框的功能,從而有了這篇關(guān)于UIAlertController的學習筆記。

關(guān)于UIAlertController

??UIAlertController 是 iOS SDK 中提供的一個強大且靈活的類,它可以用來顯示警告框或者動作表。UIAlertController 取代了早期的 UIAlertView 和 UIActionSheet 類,提供了更加統(tǒng)一和靈活的界面。

具體操作及代碼實現(xiàn)

//創(chuàng)建一個UIAlertController對象
//P1:彈出框的標題  P2彈出框的內(nèi)容  
//P3:彈出的警告框的樣式為UIAlertControllerStyleAlert(即中心彈出的警告框)
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"標題" message:@"這是消息" preferredStyle:UIAlertControllerStyleAlert];//添加“確認”動作按鈕到控制器上
//P1:標題文字  P2:動作樣式,有三種動作樣式:常規(guī)(default)、取消(cancel)以及警示(destruective)
//P3:用戶選中并點擊該動作時,所執(zhí)行的代碼
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"確認" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {// 用戶點擊確認按鈕后執(zhí)行的代碼
}];
//將動作按鈕添加到alertController視圖上
[alertController addAction:defaultAction];//添加“取消”動作按鈕到控制器上
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {// 用戶點擊取消按鈕后執(zhí)行的代碼
}];
//將動作按鈕添加到alertController視圖上
[alertController addAction:cancelAction];//將警告框顯示出來
[self presentViewController:alertController animated:YES completion:nil];

??這個示例創(chuàng)建了一個 UIAlertController,并設(shè)置了標題、消息以及樣式。然后,我們創(chuàng)建了兩個 UIAlertAction,一個是默認的操作,另一個是取消操作(有三種動作樣式:常規(guī)(default)、取消(cancel)以及警示(destruective))。這兩個操作都有處理器,所以當用戶點擊這些按鈕時,會執(zhí)行相應(yīng)的代碼塊。最后,我們使用 presentViewController:animated:completion: 方法來顯示警告框。

??將以上代碼放進xcode的"ViewController.h"文件的viewDidLoad函數(shù)中,運行后你會發(fā)現(xiàn),模擬器屏幕上無任何顯示,這是因為:

在 iOS 開發(fā)中,警告對話框(UIAlertController)不能直接被呈現(xiàn),必須在某個存在的視圖控制器(UIViewController)上呈現(xiàn)。這是因為UIAlertController實際上是一個視圖控制器,而所有的視圖控制器都需要一個父視圖控制器才能被用戶看到。

??為了看到警告框的效果,我們另外創(chuàng)建一個UIButton對象,用來觸發(fā)警告框。

UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];btn.frame = CGRectMake(100, 100, 80, 80);btn.backgroundColor = [UIColor cyanColor];[self.view addSubview:btn];[btn addTarget:self action:@selector(press) forControlEvents:UIControlEventTouchUpInside];

將UIAlertController相關(guān)操作放在btn的press函數(shù)里即可。完整代碼如下:

#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];btn.frame = CGRectMake(100, 100, 80, 80);btn.backgroundColor = [UIColor cyanColor];[self.view addSubview:btn];[btn addTarget:self action:@selector(press) forControlEvents:UIControlEventTouchUpInside];
}- (void) press {//創(chuàng)建一個UIAlertController對象//P1:彈出框的標題  P2彈出框的內(nèi)容//P3:彈出的警告框的樣式為UIAlertControllerStyleAlert(即中心彈出的警告框)UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"標題" message:@"這是消息" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"確認" style:UIAlertActionStyleDefault handler:nil];[alertController addAction:defaultAction];UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];[alertController addAction:cancelAction];[self presentViewController:alertController animated:YES completion:nil];
}@end

按下btn按鈕后的運行結(jié)果:
在這里插入圖片描述

總結(jié)

??當我們需要顯示一個警告對話框時,我們要在當前的視圖控制器上呈現(xiàn)它;如果當前不在視圖控制器中,但是需要顯示警告對話框,我們需要獲取到當前的視圖控制器,或者創(chuàng)建一個新的視圖控制器來呈現(xiàn)警告對話框。

http://www.risenshineclean.com/news/22110.html

相關(guān)文章:

  • 免費游戲網(wǎng)頁入口西安網(wǎng)站seo外包
  • 深圳雙語網(wǎng)站制作網(wǎng)站的seo是什么意思
  • 怎么做裝修網(wǎng)站seo優(yōu)化招商
  • 家裝建材網(wǎng)購平臺推薦seo外鏈平臺
  • 做網(wǎng)站廠家廣告策劃公司
  • 做網(wǎng)站客戶沒有付定金深圳網(wǎng)站優(yōu)化推廣
  • 前端開發(fā)培訓機構(gòu)成都西安官網(wǎng)seo
  • 畢業(yè)設(shè)計做系統(tǒng)跟做網(wǎng)站哪個容易打廣告去哪個平臺免費
  • 香港做批發(fā)的網(wǎng)站有哪些手續(xù)合肥做網(wǎng)站哪家好
  • 音樂播放網(wǎng)站開發(fā)pc端設(shè)計師網(wǎng)站
  • 論壇門戶網(wǎng)站建設(shè)seo文章外包
  • 新網(wǎng)站快速提高排名cdq百度指數(shù)
  • 今天長沙做營銷推廣seo
  • app商城網(wǎng)站開發(fā)百度sem推廣具體做什么
  • 網(wǎng)站沒備案怎么做加速谷歌推廣外貿(mào)建站
  • 西安手機網(wǎng)站建設(shè)動力無限福州百度推廣優(yōu)化排名
  • 淄博網(wǎng)站建設(shè)服務(wù)商發(fā)帖子最好的幾個網(wǎng)站
  • 好文案網(wǎng)站seo范疇有哪些
  • 秦皇島網(wǎng)站設(shè)計seo引擎優(yōu)化怎么做
  • 重慶觀音橋旅游攻略寧波seo的公司聯(lián)系方式
  • 怎么優(yōu)化網(wǎng)站每日新聞
  • 網(wǎng)站開發(fā) 需求清單英文谷歌優(yōu)化
  • 秦皇島十大必去景點贛州seo顧問
  • 武漢網(wǎng)站seo德升品牌策劃包括哪幾個方面
  • 個人網(wǎng)站備案可以做項目網(wǎng)站seo哪家好
  • 網(wǎng)站建設(shè)推廣運營推廣網(wǎng)站有效的免費方法
  • 網(wǎng)站關(guān)鍵字優(yōu)化教程一元友情鏈接平臺
  • 小程序開發(fā)定制制優(yōu)化大師平臺
  • wordpress 網(wǎng)站維護近期網(wǎng)絡(luò)輿情事件熱點分析
  • 陜西整站關(guān)鍵詞自然排名優(yōu)化湖南網(wǎng)絡(luò)推廣機構(gòu)