0

I'm using custom UIViews to as navigationBarItem (like Facebook does it in their iOS app).

UIImageView *linkesMenu = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"187menu.png"]];
UIBarButtonItem *barItem = [[UIBarButtonItem alloc] initWithCustomView:linkesMenu];

barItem.action = @selector(MenuSlider:);
self.navigationItem.leftBarButtonItem = barItem;

I tried this and a couple other things but nothing works really.

woz
  • 10,888
  • 3
  • 34
  • 64
Constantin Jacob
  • 488
  • 1
  • 8
  • 21

1 Answers1

0

Try putting the image into a button first:

UIImage *theImage = [UIImage imageNamed:@"image.png"];
UIButton *theButton = [UIButton buttonWithType:UIButtonTypeCustom];
theButton.bounds = CGRectMake(0, 0, theImage.size.width, theImage.size.height);
[theButton setImage:theImage forState:UIControlStateNormal];
UIBarButtonItem *theBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:theButton];


[theButton addTarget:self action:@selector(MenuSlider:) forControlEvent:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = barItem;
Constantin Jacob
  • 488
  • 1
  • 8
  • 21
woz
  • 10,888
  • 3
  • 34
  • 64