SORU
5 NİSAN 2012, PERŞEMBE


Nasıl bir UİBarButtonİtem gizlemek göstermek için ne yapmalıyım?

Birçok düğme ile İB bir araç yarattım. /Göster düğmeleri ana penceresinde veri durumuna bağlı olarak bir gizlemek mümkün olmak istiyorum.

UİBarButtonİtem yok gizli bir özellik ve herhangi bir örnek buldum şimdiye kadar gizlediği almalarını ayarı gezinme çubuğu düğmeleri yoktur, sanmıyorum yapmak istiyorum çünkü ihtiyacım olabilir göstermek için düğmeyi yeniden (söz etmiyorum bile, eğer ben Bağlan düğmesini bir İBOutlet, eğer benim hazırladığım nil emin değilim nasıl isterdim Geri Al).

CEVAP
5 NİSAN 2012, PERŞEMBE


Bir düğmeye kaydedingüçlüçıkış ve bu Ekleme Yap/Kaldır:

// Get the reference to the current toolbar buttons
NSMutableArray *toolbarButtons = [self.toolbarItems mutableCopy];

// This is how you remove the button from the toolbar and animate it
[toolbarButtons removeObject:self.myButton];
[self setToolbarItems:toolbarButtons animated:YES];

// This is how you add the button to the toolbar and animate it
if (![toolbarButtons containsObject:self.myButton]) {
    // The following line adds the object to the end of the array.  
    // If you want to add the button somewhere else, use the `insertObject:atIndex:` 
    // method instead of the `addObject` method.
    [toolbarButtons addObject:self.myButton];
    [self setToolbarItems:toolbarButtons animated:YES];
}

Outlet saklı olduğu için, araç çubuğunda değil de bir referans devam edecektir.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • AginoEvolutionHD

    AginoEvoluti

    27 AĞUSTOS 2011
  • Krumme1996

    Krumme1996

    21 EYLÜL 2009
  • Moodle

    Moodle

    11 Mayıs 2010