0

I'm trying to make an audio player, and have a toolbar on bottom. I programmatically add a barbutton item with a UIImageView as it's customView property, but when the image displays it is barely on screen: enter image description here the image is Pause@2x.png, is 40x40 pixels, and this is how I add the button

UIBarButtonItem *flex1, *flex2;
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Pause@2x.png"]];
self.play = [[UIBarButtonItem alloc] initWithCustomView:iv];
[self.play setAction:@selector(pauseButtonClicked:)];
flex1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
flex2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[self.bar setItems:@[flex1, _play, flex2]];

Pause.png enter image description here Pause@2x.png enter image description here

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
Chris Loonam
  • 5,735
  • 6
  • 41
  • 63
  • There is no point calling `setAction:` on a UIBarButtonItem created with `initWithCustomView`. It is not a button; it leaves touch handling entirely to the custom view. (The docs are quite clear on this point.) – matt Apr 26 '13 at 23:52

1 Answers1

0

I was trying to change the toolbar's height later in the code, removing that line fixed it.

Chris Loonam
  • 5,735
  • 6
  • 41
  • 63