Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 9,Swift 2.1-删除垂直布局中的警报_Ios_Swift - Fatal编程技术网

iOS 9,Swift 2.1-删除垂直布局中的警报

iOS 9,Swift 2.1-删除垂直布局中的警报,ios,swift,Ios,Swift,我有一个普通风格的警告,显示了2个按钮水平与以下实现,我想知道我如何才能使它像附加的图像 let alert = UIAlertController(title: "", message: "This item will be deleted", preferredStyle: .Alert) alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)); alert

我有一个普通风格的警告,显示了2个按钮水平与以下实现,我想知道我如何才能使它像附加的图像

let alert = UIAlertController(title: "", message: "This item will be deleted", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil));
alert.addAction(UIAlertAction(title: "Delete", style: UIAlertActionStyle.Destructive, handler: {
        alertAction in
        self.deleteItem(sender)
}))
presentViewController(alert, animated: true, completion: nil);
使用这个:-

let alert = UIAlertController(title: "", message: "This item will be deleted", preferredStyle: .ActionSheet)
使用这个:-

let alert = UIAlertController(title: "", message: "This item will be deleted", preferredStyle: .ActionSheet)

您可以将以下内容用于您想要实现的目标

@IBAction func actionRecommend(sender: UIButton) {


        let optionMenu = UIAlertController(title: nil, message: "Recommend Using", preferredStyle: .ActionSheet)
        optionMenu.view.tintColor = primaryDarkColor

        let deleteAction = UIAlertAction(title: "Facebook", style: .Default, handler: {
            (alert: UIAlertAction!) -> Void in
            print("File Facebook")
        })

        let saveAction = UIAlertAction(title: "Contacts", style: .Default, handler: {
            (alert: UIAlertAction!) -> Void in
            print("File toContacts")
           // self.performSegueWithIdentifier("toContacts", sender: nil)

         })

        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
            (alert: UIAlertAction!) -> Void in
            print("Cancelled")
        })


        optionMenu.addAction(deleteAction)
        optionMenu.addAction(saveAction)
        optionMenu.addAction(cancelAction)

        self.presentViewController(optionMenu, animated: true, completion: nil)

    }

您可以将以下内容用于您想要实现的目标

@IBAction func actionRecommend(sender: UIButton) {


        let optionMenu = UIAlertController(title: nil, message: "Recommend Using", preferredStyle: .ActionSheet)
        optionMenu.view.tintColor = primaryDarkColor

        let deleteAction = UIAlertAction(title: "Facebook", style: .Default, handler: {
            (alert: UIAlertAction!) -> Void in
            print("File Facebook")
        })

        let saveAction = UIAlertAction(title: "Contacts", style: .Default, handler: {
            (alert: UIAlertAction!) -> Void in
            print("File toContacts")
           // self.performSegueWithIdentifier("toContacts", sender: nil)

         })

        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
            (alert: UIAlertAction!) -> Void in
            print("Cancelled")
        })


        optionMenu.addAction(deleteAction)
        optionMenu.addAction(saveAction)
        optionMenu.addAction(cancelAction)

        self.presentViewController(optionMenu, animated: true, completion: nil)

    }

更改preferredStyle:。代码中的ActionSheet.is您的问题解决方案更改preferredStyle:。代码中的ActionSheet.is您的问题解决方案我没想到会这么简单。。不错!给我几分钟,直到它允许我:)我没想到它会这么简单。。不错!给我几分钟,直到它允许我:)