2016-04-26 77 views
0

アラートアクションからタイトルセクションを削除します。アラートアクションをタイトルなしで作成する方法

enter image description here

をどのように私はすべて一緒にタイトルセクションを削除することができます。 作るタイトル文字列""はタイトルセクション

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

} 

は削除されませんこれは私が取得しています何ですか?

+0

空の文字列の代わりに 'nil'を渡してみましたか?それはオプションの値 – bobDevil

+0

ああ..働いています。回答として投稿したい場合は、私はそれを受け入れます。 –

答えて

4

"title"はオプションの値です。空の文字列の代わりにnilを渡すと、タイトル領域が取り除かれます。

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

+0

素晴らしいチップ! :) – Fattie

関連する問題