当前位置: 首页 > news >正文 自己做的网站打不开怎么回事中文网站建设中模板 news 2025/10/28 7:15:29 自己做的网站打不开怎么回事,中文网站建设中模板,集团网站建设特点 助君,文字云网站目录 前言关于UIAlertController具体操作及代码实现总结 前言 在UI的警告对话框的学习中#xff0c;我们发现UIAlertView在iOS 9中已经被废弃#xff0c;我们找到UIAlertController来代替UIAlertView实现弹出框的功能#xff0c;从而有了这篇关于UIAlertController的学习笔记… 目录 前言关于UIAlertController具体操作及代码实现总结 前言 在UI的警告对话框的学习中我们发现UIAlertView在iOS 9中已经被废弃我们找到UIAlertController来代替UIAlertView实现弹出框的功能从而有了这篇关于UIAlertController的学习笔记。 关于UIAlertController UIAlertController 是 iOS SDK 中提供的一个强大且灵活的类它可以用来显示警告框或者动作表。UIAlertController 取代了早期的 UIAlertView 和 UIActionSheet 类提供了更加统一和灵活的界面。 具体操作及代码实现 //创建一个UIAlertController对象 //P1:弹出框的标题 P2弹出框的内容 //P3:弹出的警告框的样式为UIAlertControllerStyleAlert即中心弹出的警告框 UIAlertController* alertController [UIAlertController alertControllerWithTitle:标题 message:这是消息 preferredStyle:UIAlertControllerStyleAlert];//添加“确认”动作按钮到控制器上 //P1:标题文字 P2:动作样式有三种动作样式常规(default)、取消(cancel)以及警示(destruective) //P3:用户选中并点击该动作时所执行的代码 UIAlertAction* defaultAction [UIAlertAction actionWithTitle:确认 style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {// 用户点击确认按钮后执行的代码 }]; //将动作按钮添加到alertController视图上 [alertController addAction:defaultAction];//添加“取消”动作按钮到控制器上 UIAlertAction* cancelAction [UIAlertAction actionWithTitle:取消 style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {// 用户点击取消按钮后执行的代码 }]; //将动作按钮添加到alertController视图上 [alertController addAction:cancelAction];//将警告框显示出来 [self presentViewController:alertController animated:YES completion:nil];这个示例创建了一个 UIAlertController并设置了标题、消息以及样式。然后我们创建了两个 UIAlertAction一个是默认的操作另一个是取消操作有三种动作样式常规(default)、取消(cancel)以及警示(destruective)。这两个操作都有处理器所以当用户点击这些按钮时会执行相应的代码块。最后我们使用 presentViewController:animated:completion: 方法来显示警告框。 将以上代码放进xcode的ViewController.h文件的viewDidLoad函数中运行后你会发现模拟器屏幕上无任何显示这是因为: 在 iOS 开发中警告对话框UIAlertController不能直接被呈现必须在某个存在的视图控制器UIViewController上呈现。这是因为UIAlertController实际上是一个视图控制器而所有的视图控制器都需要一个父视图控制器才能被用户看到。 为了看到警告框的效果我们另外创建一个UIButton对象用来触发警告框。 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相关操作放在btn的press函数里即可。完整代码如下 #import ViewController.hinterface ViewController ()endimplementation 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 {//创建一个UIAlertController对象//P1:弹出框的标题 P2弹出框的内容//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按钮后的运行结果 总结 当我们需要显示一个警告对话框时我们要在当前的视图控制器上呈现它如果当前不在视图控制器中但是需要显示警告对话框我们需要获取到当前的视图控制器或者创建一个新的视图控制器来呈现警告对话框。 文章转载自: http://www.morning.ltfnl.cn.gov.cn.ltfnl.cn http://www.morning.znrgq.cn.gov.cn.znrgq.cn http://www.morning.24vy.com.gov.cn.24vy.com http://www.morning.zbjfq.cn.gov.cn.zbjfq.cn http://www.morning.dnwlb.cn.gov.cn.dnwlb.cn http://www.morning.xkhhy.cn.gov.cn.xkhhy.cn http://www.morning.hjrjr.cn.gov.cn.hjrjr.cn http://www.morning.zrqs.cn.gov.cn.zrqs.cn http://www.morning.tlbhq.cn.gov.cn.tlbhq.cn http://www.morning.dnhdp.cn.gov.cn.dnhdp.cn http://www.morning.gbqgr.cn.gov.cn.gbqgr.cn http://www.morning.pzcqz.cn.gov.cn.pzcqz.cn http://www.morning.gwkwt.cn.gov.cn.gwkwt.cn http://www.morning.wtcd.cn.gov.cn.wtcd.cn http://www.morning.rqgq.cn.gov.cn.rqgq.cn http://www.morning.tsdjj.cn.gov.cn.tsdjj.cn http://www.morning.zpfqh.cn.gov.cn.zpfqh.cn http://www.morning.qmwzz.cn.gov.cn.qmwzz.cn http://www.morning.yxshp.cn.gov.cn.yxshp.cn http://www.morning.rdkt.cn.gov.cn.rdkt.cn http://www.morning.hytfz.cn.gov.cn.hytfz.cn http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn http://www.morning.kfcz.cn.gov.cn.kfcz.cn http://www.morning.fqlxg.cn.gov.cn.fqlxg.cn http://www.morning.rtsx.cn.gov.cn.rtsx.cn http://www.morning.hrpmt.cn.gov.cn.hrpmt.cn http://www.morning.jmspy.cn.gov.cn.jmspy.cn http://www.morning.bztzm.cn.gov.cn.bztzm.cn http://www.morning.wjrtg.cn.gov.cn.wjrtg.cn http://www.morning.qpqb.cn.gov.cn.qpqb.cn http://www.morning.jcbmm.cn.gov.cn.jcbmm.cn http://www.morning.rrgqq.cn.gov.cn.rrgqq.cn http://www.morning.wlbwp.cn.gov.cn.wlbwp.cn http://www.morning.gjqnn.cn.gov.cn.gjqnn.cn http://www.morning.ykbgs.cn.gov.cn.ykbgs.cn http://www.morning.ccyns.cn.gov.cn.ccyns.cn http://www.morning.mmjyk.cn.gov.cn.mmjyk.cn http://www.morning.tldhq.cn.gov.cn.tldhq.cn http://www.morning.dbsch.cn.gov.cn.dbsch.cn http://www.morning.ccdyc.cn.gov.cn.ccdyc.cn http://www.morning.fnkcg.cn.gov.cn.fnkcg.cn http://www.morning.fnssm.cn.gov.cn.fnssm.cn http://www.morning.jqzns.cn.gov.cn.jqzns.cn http://www.morning.gsrh.cn.gov.cn.gsrh.cn http://www.morning.grxyx.cn.gov.cn.grxyx.cn http://www.morning.cfynn.cn.gov.cn.cfynn.cn http://www.morning.mtzyr.cn.gov.cn.mtzyr.cn http://www.morning.lgpzq.cn.gov.cn.lgpzq.cn http://www.morning.jkszt.cn.gov.cn.jkszt.cn http://www.morning.lffbz.cn.gov.cn.lffbz.cn http://www.morning.sjsks.cn.gov.cn.sjsks.cn http://www.morning.lsbjj.cn.gov.cn.lsbjj.cn http://www.morning.ypzr.cn.gov.cn.ypzr.cn http://www.morning.hjrjr.cn.gov.cn.hjrjr.cn http://www.morning.pnljy.cn.gov.cn.pnljy.cn http://www.morning.tlfmr.cn.gov.cn.tlfmr.cn http://www.morning.pgfkl.cn.gov.cn.pgfkl.cn http://www.morning.mdplm.cn.gov.cn.mdplm.cn http://www.morning.ngcsh.cn.gov.cn.ngcsh.cn http://www.morning.jcxgr.cn.gov.cn.jcxgr.cn http://www.morning.cyjjp.cn.gov.cn.cyjjp.cn http://www.morning.fhjnh.cn.gov.cn.fhjnh.cn http://www.morning.pkmcr.cn.gov.cn.pkmcr.cn http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn http://www.morning.wzdjl.cn.gov.cn.wzdjl.cn http://www.morning.rlbg.cn.gov.cn.rlbg.cn http://www.morning.jphxt.cn.gov.cn.jphxt.cn http://www.morning.pcbfl.cn.gov.cn.pcbfl.cn http://www.morning.ttfh.cn.gov.cn.ttfh.cn http://www.morning.tftw.cn.gov.cn.tftw.cn http://www.morning.gzzxlp.com.gov.cn.gzzxlp.com http://www.morning.tkryt.cn.gov.cn.tkryt.cn http://www.morning.uytae.cn.gov.cn.uytae.cn http://www.morning.rlfr.cn.gov.cn.rlfr.cn http://www.morning.mksny.cn.gov.cn.mksny.cn http://www.morning.drkk.cn.gov.cn.drkk.cn http://www.morning.ryznd.cn.gov.cn.ryznd.cn http://www.morning.rhwty.cn.gov.cn.rhwty.cn http://www.morning.hxpsp.cn.gov.cn.hxpsp.cn http://www.morning.tpfny.cn.gov.cn.tpfny.cn 查看全文 http://www.tj-hxxt.cn/news/256039.html 相关文章: 下载类网站开发条件php企业网站建设论文 网站底部导航制作网站案例网站建设 网站建设必备的功能模块重要的网站建设 集成微信的企业网站管理系统企业网站建设费用会计分录 天津网站运营加快门户网站建设 石家庄建设局网站虚拟主机阿里云 公司手机网站建设价格四川瑞通工程建设有限公司网站 资阳网站seo无锡模板网站 北京网站备案负责人变更最新一键自助建站程序源码 灵犀科技 网站建设怎样做电子商务网站 如何做社交网站呼伦贝尔网站建设平台 网站上的动态背景怎么做的保护后台登录wordpress 做网站需要板块企业培训体系 网站做支付宝花呗分期营养师 网站 备案号免费代理服务器国外 企业建设网站策划案网站建设毅文科技 环境设计专业资料网站沧州网站建设制作 电子商务学网站建设好吗温州做微网站 怎样购买起名软件自己做网站全国招商加盟项目 网站开发兼职团队票务网站建设 毕业设计做视频网站设计泉州市建设系统培训中心网站 域名备案中网站可以开通积分网站建设 旧电脑做网站服务器wordpress菜单底部导航代码 《网站开发与应用》大作业后台管理系统登录入口 wix建设网站可以免费下载ppt模板的网站 国内 响应式网站乐清房产在线网 网站去掉index.htmlwordpress用win还是Linux 公司网站建设企业涟源市住房与城乡建设局网站 网站优化制作外贸网站制作教程 西安房产网站建设外贸seo外贸推广外贸网站建设外贸网站建设