0

I have a problem - my app got rejected 3 times for the same reason, "Selecting the Action button does not produce an action". Apple said the "share button" isn't working as well. On my devices (ipod 4 + ipod 5) and the iphone simulation, the share button works, and opens an action sheet view with 3 options to choose from, and they all work fine.

The share button is a UIBarButtonItem and stand on the UINavigationBar. the back button and the star button work great, but still the share button is not responding and doesn't produce any action.

enter image description here This is my app screenshot.

This is my button code:

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0, 0, 33, 22);
    [rightButton setBackgroundImage:[UIImage imageNamed:@"btn_share.png"] forState:UIControlStateNormal];
    [rightButton setBackgroundImage:[UIImage imageNamed:@"btn_shareSelect.png"] forState:UIControlStateHighlighted];
    [rightButton addTarget:self action:@selector(share) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem=rightItem;

What can I do? Is there a way to solve this?

4

1 回答 1

0

Can you reproduce the problem yourself? It would be a good start.

I think you may be having a problem because you're adding a target to the UIButton custom view and not the actual bar button item.

So please try setting the action and target properties on the UIbarButtonItem itself. Be sure to remove the rightButton addTarget line.

If that doesn't work, I'd then try not using a UIbutton for the custom view.

Btw, why aren't you just using UIBarButtonItem initWithBarButtonSystemItem:? i think the "action" style will give you the look you want, with less hassle.

于 2013-01-13T11:53:11.360 回答