Sunday, 8 September 2013

Why I can't use a block to add a leftBarButtonItem

Why I can't use a block to add a leftBarButtonItem

Here is the code:
self.navigationItem.leftBarButtonItem = kMenuIcon;
and here is my kMenuIcon:
#define kMenuIcon ^{UIBarButtonItem *menuIcon = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"more_icon"]
style:UIBarButtonItemStylePlain target:self
action:@selector(revealLeftSidebar:)]; return menuIcon;};
But it return me the unrecognized selector error like this:
-[NSStackBlock isSystemItem]: unrecognized selector sent to instance
0xbfffd4b8 2013-09-09 11:30:57.788 Sircle[33182:c07] Uncaught exception:
-[NSStackBlock isSystemItem]: unrecognized selector sent to instance
0xbfffd4b8
I tried that code, move away from the block, it works, but when I put it
in the block, it doesn't. What's going wrong? Thanks.

No comments:

Post a Comment