ios - 这个弹出窗口类的名称是什么?

标签 ios swift uiview

我找不到这个“popover”的类名。 Apple 在他们的应用程序中大量使用它。

我搜索了 popoverNSAlert、自定义隐藏/可见 View 等等。

它叫什么?

enter image description here

最佳答案

这是 UIAlertController。在 ios7 之前它被称为 UIActionSheet

UIAlertController 对象向用户显示警告消息。此类替换了用于显示警报的 UIActionSheet 和 UIAlertView 类。

    @IBAction func showActionSheetTapped(sender: AnyObject) {
  //Create the AlertController
  let actionSheetController: UIAlertController = UIAlertController(title: "Action Sheet", message: "Swiftly Now! Choose an option!", preferredStyle: .ActionSheet)

  //Create and add the Cancel action
  let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
    //Just dismiss the action sheet
  }
  actionSheetController.addAction(cancelAction)
    //Create and add first option action
  let takePictureAction: UIAlertAction = UIAlertAction(title: "Take Picture", style: .Default) { action -> Void in
    //Code for launching the camera goes here
    }
  actionSheetController.addAction(takePictureAction)
  //Create and add a second option action
  let choosePictureAction: UIAlertAction = UIAlertAction(title: "Choose From Camera Roll", style: .Default) { action -> Void in
    //Code for picking from camera roll goes here
    }
  actionSheetController.addAction(choosePictureAction)

  //Present the AlertController
  self.presentViewController(actionSheetController, animated: true, completion: nil)
}

输出:

enter image description here

也许它会对你有所帮助。

关于ios - 这个弹出窗口类的名称是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33515641/

相关文章:

swift - 为什么 Swift 不允许在扩展中存储属性?

ios - insertSubview :belowSubview doesnt work 的简单案例

iphone - 在 Cocoa Touch 中旋转 UIView

ios - 使用委托(delegate)将数据从模态视图传递到父 View (在 Storyboard中使用 segue)

ios - AVAudioSession 未检测到已连接的蓝牙设备

android - ionic/cordova应用程序中的“编辑权限”链接

ios - RxSwift 重新加载表格 View

ios - 在swift 4中创建一个包含数组和字典的字典

ios - 带有 UITableViewController 的 searchResultsController 隐藏了导航栏,如何防止呢?

ios - 突出显示和取消突出显示 UIView