弹出提示框

方式一:底部弹出提示框(UIActionSheet)

  • 调用initWithTitle:delegate:cancelButtonTitle:取消destructiveButtonTitle:确定otherButtonTitle:
  • showInView:self.view
  • 遵守协议<UIActionSheetDelegate>
  • 实现代理方法
    • clickButtonAtIndex:当buttonIndex == 0时,返回到上一级

方式二:中间弹出(UIAlertView)

  • 调用initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:
  • show

方式三:UIAlertController(可以实现上面两种效果)

  • 创建控制器

    • alertControllerWithTitle:message:preferredStyle:弹出指定的样式
  • 创建按钮 UIAlertAction
    -点击按钮的时候会调用这个方法 ,可以做pop操作。actionWithTitle:style:handler:^(){}

  • 把按钮添加到控制器上,有几个添加几个addAction

  • 弹框modal形式弹出

    • presentViewController:animated:completion:
  • 注意:只有alert样式的时候,才可以添加文本框。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容