这个popover类的名称是什么?

时间:2015-11-04 07:04:24

标签: ios swift uiview

我无法找到此“popover”类的名称。 Apple在他们的应用程序中大量使用它。

我搜索了popoverNSAlert,自定义隐藏/可见视图等等。

它叫什么?

enter image description here

1 个答案:

答案 0 :(得分:2)

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

UIAlertController对象向用户显示警告消息。此类替换UIActionSheet和U​​IAlertView类以显示警报。

    @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

可能会帮助你。