2016-04-26 144 views
0

我想從警報動作中刪除標題部分。 製作標題字符串""不會刪除標題部分如何使警報動作無標題

@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) 

} 

這就是我得到:

enter image description here

如何刪除標題節中的所有在一起嗎?

+0

您是否嘗試過傳遞'nil'而不是空字符串?這是一個可選值 – bobDevil

+0

ahh ..這很有效。如果你想發佈它作爲答案,我會接受它。 –

回答

4

「title」是一個可選的值,如果你傳遞nil而不是空字符串,它將擺脫標題區域。

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

+0

奇妙的提示! :) – Fattie