2016-10-26 4 views
-1

ich den folgenden Codeeine Schaltfläche, um die native Symbolleiste hinzufügen

final class MyViewController: UIViewController, 
    UICollectionViewDataSource, UICollectionViewDelegate, /*..*/ { 

    // 
    // Declaring local variables, other controllers and delegates etc. 
    // 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     let item = UIBarButtonItem(title: "A button that should do nothing", 
      style: .Plain, target: nil, action: nil) 

     self.navigationController!.toolbar.items = [item] 

     self.navigationController!.toolbarHidden = false 
    } 

    // the rest of my code 
} 

Und egal, was ich tue, wird die Symbolleiste, aber nichts in der es machen.

Ich habe auch versucht

self.navigationController?.toolbarItems?.insert(item, atIndex: 0) 

die Einfügung des Artikels zu tun, aber noch kein Glück.

Was mache ich falsch?

Antwort

-1

Feste durch das Hinzufügen von Elementen über

self.toolbarItems = [item] 
Verwandte Themen