RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
IOS中如何实现弹框

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

目前累计服务客户上1000+,积累了丰富的产品开发及服务经验。以网站设计水平和技术实力,树立企业形象,为客户提供网站设计、成都网站建设、网站策划、网页设计、网络营销、VI设计、网站改版、漏洞修补等服务。创新互联建站始终以务实、诚信为根本,不断创新和提高建站品质,通过对领先技术的掌握、对创意设计的研究、对客户形象的视觉传递、对应用系统的结合,为客户提供更好的一站式互联网解决方案,携手广大客户,共同发展进步。

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中如何实现弹框”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


分享文章:IOS中如何实现弹框
本文路径:http://scyingshan.cn/article/ghhdoo.html