Jason
Jason

Reputation: 2455

Custom Toolbar UIBarButtonItem images - What am i doing wrong?

here is the code:

http://pastebin.com/zQXmYgzJ

It crashes at runtime at the line:

UISegmentedControl *segmentedControl = [[[UISegmentedControl alloc] initWithItems:toolbarItems]autorelease];

with the error

"'-[UIBarButtonItem isEqualToString:]: unrecognized selector sent to instance 0x4b2e780'"

I can't understand this error message... everything seems to be fine as in the debugger i can see that a 3 object array of bar buttons is being passed to segmented control... does anyone have an idea why I am hitting runtim errors here?

Upvotes: 0

Views: 421

Answers (1)

Bogatyr
Bogatyr

Reputation: 19323

You can't pass in an array of UIBarButtonItems, only NSString or UIImage:

initWithItems: Initializes and returns a segmented control with segments having the given titles or images.

  • (id)initWithItems:(NSArray *)items Parameters items An array of NSString objects (for segment titles) or UIImage objects (for segment images).

Upvotes: 2

Related Questions