Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jvpython

macrumors 6502
Original poster
Aug 25, 2011
284
0
New Zealand
I've been having an issue in an app that I've developed under Xcode 4.5 DP4 where nothing happens when the user taps a Bar Button Item linked to an Action. I have tried several method for doing this such as linking the Bar Button Item inside a toolbar to an IBAction and also doing this programatically like this:

Code:
theButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonItemStyleBordered target: s:confused:elf action: @selector(theButtonPressed:)];

But none of these seem to work as nothing happens when the button is pressed. I never had this issue in previous versions of iOS. Does anyone have any idea what the problem is here? Thanks
 
Code:
theButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonItemStyleBordered target: s:confused:elf action: @selector(theButtonPressed:)];

How did you declare theButtonPressed? If its declared like

Code:
-(void)theButtonPressed {...}

then you need to use
Code:
@selector(theButtonPressed)
not:
Code:
@selector(theButtonPressed:)
 
I've been having an issue in an app that I've developed under Xcode 4.5 DP4 where nothing happens when the user taps a Bar Button Item linked to an Action. I have tried several method for doing this such as linking the Bar Button Item inside a toolbar to an IBAction and also doing this programatically like this:

Code:
theButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonItemStyleBordered target: s:confused:elf action: @selector(theButtonPressed:)];

But none of these seem to work as nothing happens when the button is pressed. I never had this issue in previous versions of iOS. Does anyone have any idea what the problem is here? Thanks

The code you posted does not make sense. "...target: s:confused:elf action:..." The syntax for method calls should be

[object methodname: param1
paramName2: paramvalue2
paramName3: paramValue3...
<paraNameX: paramValueX>]

You should have matched pairs of key:value entries. If you have a:b:c, something is wrong.
 
The code you posted does not make sense. "...target: s:confused:elf action:..." The syntax for method calls should be

[object methodname: param1
paramName2: paramvalue2
paramName3: paramValue3...
<paraNameX: paramValueX>]

You should have matched pairs of key:value entries. If you have a:b:c, something is wrong.

The ":confused:" part just appeared when I copy pasted and posted the code. It was supposed to be there ;)
 
How did you declare theButtonPressed? If its declared like

Code:
-(void)theButtonPressed {...}

then you need to use
Code:
@selector(theButtonPressed)
not:
Code:
@selector(theButtonPressed:)

Thanks for the info, but I just checked the code and it's fine. The strangest thing is that when I simply link the button to an IBAction from Interface Builder it actually works in the simulator but on my iPhone...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.