新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

IOS中如何实现弹框-创新互联

这篇文章主要介绍了IOS中如何实现弹框,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

创新互联建站是一家集网站建设,乳源企业网站建设,乳源品牌网站建设,网站定制,乳源网站建设报价,网络营销,网络优化,乳源网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

IOS 中弹框的实现方法整理

#define iOS8Later ([UIDevice currentDevice].systemVersion.doubleValue >= 8.0)

ios 8以前的弹框

@interface RootViewController () 
 
@end
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"登陆失败" message:@"请重新输入用户名和密码" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; 
      [alert show];
#pragma mark - UIAlertView Delegate Methods - 
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
  if(buttonIndex == 0) 
  { 
    NSLog(@"点击取消按钮后,想要的操作,可以加此处"); 
  } 
  else if(buttonIndex == 1) 
  { 
    NSLog(@"点击确定按钮后,想要的操作,可以加此处"); 
  } 
}

ios8以后的弹框

  UIAlertController *_alertVC = [UIAlertController alertControllerWithTitle:@"登陆失败" message:@"请重新输入用户名和密码" preferredStyle:UIAlertControllerStyleAlert]; 
       
      //警告类型,红色字体 UIAlertActionStyleDestructive 
//      UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:nil]; 
//      [_alertVC addAction:_doAction]; 
       
      UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) 
      { 
        NSLog(@"点击确定按钮后,想要的操作,可以加此处"); 
      }]; 
      [_alertVC addAction:_doAction]; 
 
//      UIAlertAction *_cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; 
//      [_alertVC addAction:_cancleAction]; 
       
      UIAlertAction *_cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) 
      { 
        NSLog(@"点击取消按钮后,想要的操作"); 
      }]; 
      [_alertVC addAction:_cancleAction]; 
       
      [self presentViewController:_alertVC animated:YES completion:nil];
//警告类型,红色字体 UIAlertActionStyleDestructive,如下图所示的效果

      UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:nil];

      [_alertVC addAction:_doAction];

IOS中如何实现弹框

感谢你能够认真阅读完这篇文章,希望小编分享的“IOS中如何实现弹框”这篇文章对大家有帮助,同时也希望大家多多支持创新互联建站,关注创新互联网站建设公司行业资讯频道,更多相关知识等着你来学习!

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


标题名称:IOS中如何实现弹框-创新互联
URL标题:http://www.wjwzjz.com/article/cejdoo.html
在线咨询
服务热线
服务热线:028-86922220
TOP