2015-04-21 25 views
31

UIAlertController kullanırken, boş bir başlık ve boş bir ileti ile bir UIActionSheet10 sunmak istiyorsanız, başlık ve/veya iletinin beklenen yerleştirme için çerçeve kalır.

Ayarlar
İşaret dışarı
İptal: Ben sadece okur bir ActionSheet sunmak, böyleceBir UIAlertController'da başlık/mesaj çerçevesini nasıl gizleyebilirim?

Bunu nasıl değiştirebilirim?

Teşekkürler! Bu kod ile bir UIAlertController oluşturduğunuzda

UIAlertController example

cevap

76

Ben başlık aralığını yok.

[UIAlertController alertControllerWithTitle:nil 
            message:nil 
          preferredStyle:UIAlertControllerStyleActionSheet]; 

Başlık ve ileti veya boş dizeler için sıfırdan mı geçiyorsunuz?

+1

Bu oldukça basitti. Ve bu benim sorumu yanıtladı. Teşekkürler – vlin

0

UIAlertController * kontrol = [UIAlertController alertControllerWithTitle: @ "" iletisi: @ "" preferredStyle: UIAlertControllerStyleAlert]; // stil onay

UIAlertAction *first = [UIAlertAction actionWithTitle: @"Login with Facebook" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) 
{ 
    //write to perform action 

}]; 


[controller addAction: first]; 



UIAlertAction *second = [UIAlertAction actionWithTitle: @"Guest User" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) 

{ // eylemi

}]; 

[controller addAction:second]; 


UIAlertAction *third=[UIAlertAction actionWithTitle:@"Registered User" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) 


{ 
    //write to perform action 

}]; 

[controller addAction:third]; 

[self presentViewController: controller animated: YES completion: nil]; 
3
gerçekleştirmek için mal

Belirli bir duruma bağlı olarak çalışma zamanında değiştirmek isterseniz, aşağıdakileri yazın:

actionController.title = nil
hızlı 2.2 olarak actionController.message = nil

0

, aşağıdaki kodu kullanabilirsiniz ve ayrıca SignOut eylem düğme rengini değiştirmiş

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

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

    let settingsActionButton: UIAlertAction = UIAlertAction(title: "Settings", style: .Cancel) { action -> Void in 
     print("Settings Tapped") 
    } 

    reportActionSheet.addAction(settingsActionButton) 

    let signOutActionButton: UIAlertAction = UIAlertAction(title: "Signout", style: .Default) 
    { action -> Void in 
     //Clear All Method 
     print("Signout Tapped") 

    } 

    signOutActionButton.setValue(UIColor.redColor(), forKey: "titleTextColor") 

    actionSheet.addAction(signOutActionButton) 

    let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in 
     print("Cancel Tapped") 
    } 

    reportActionSheet.addAction(cancelActionButton) 
0

Güncelleme Swift 4:

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

Sadece geçmesi gerekiyor başlık ve mesaj paramları nil.

Teşekkürler

İlgili konular