Search code examples
iosiphoneuibarbuttonitemuitoolbar

Outlets to UIBarButtonItems not working


I have a UIToolbar. This toolbar has two elements, an image and a slider. The image is inside a view. So each UIBarButtomItems on the toolbar has this structure

TOOLBAR
  │
  ├─────── UIBarButtomItem
  │              │
  │              │
  │            view
  │              │
  │              └─── imageView
  │
  └─────── UIBarButtomItem
                 │
                 │
               slider

This toolbar has its own class.

I have tried to drag IBOutlets from the slider, from the imageView, and even from the buttons to its class and it is not working. Xcode accepts the outlet to the viewController where the toolbar is but I was trying to separate all the logic from this toolbar from its view controller.

What is missing?


Solution

  • Try to write outlet property manually (with keyword IBOutlet) and connect in from code to UI by dragging from the empty cycle appeared from left side of property declaration.