【问题标题】:How to make Alert action title-less [duplicate]如何使警报操作无标题[重复]
【发布时间】:2016-04-26 00:08:09
【问题描述】:

我想从警报操作中删除标题部分。 制作标题字符串"" 不会删除标题部分

@IBAction func addImage(sender: AnyObject!) {

    let alert:UIAlertController = UIAlertController(title: "" ,message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

    let cameraAction = UIAlertAction(title: "Take Photo", style: UIAlertActionStyle.Default)
        {
            UIAlertAction in
            self.openCamera()
    }
    let gallaryAction = UIAlertAction(title: "Choose Photo", style: UIAlertActionStyle.Default)
        {
            UIAlertAction in
            self.openGallary()
    }
    let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel)
        {
            UIAlertAction in

    }

    // Add the actions
    alert.addAction(cameraAction)
    alert.addAction(gallaryAction)
    alert.addAction(cancelAction)

    // Present the controller
    self.presentViewController(alert, animated: true, completion: nil)

}

这就是我得到的:

如何将标题部分一起删除?

【问题讨论】:

  • 您是否尝试过传递 'nil' 而不是空字符串?这是一个可选值
  • 啊……那行得通。如果您想将其发布为答案,我会接受。

标签: ios swift uialertcontroller


【解决方案1】:

“title”是一个可选值,如果你传递nil而不是空字符串,它将摆脱标题区域。

let alert:UIAlertController = UIAlertController(title: nil ,message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

【讨论】:

  • 绝妙的提示! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 2020-02-14
  • 2020-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多