backButtonItem stuck with default behavior
I've tried a few different tweaks to get my backBarButtonItem to run different methods, but no matter what, it only executes the default behavior of backing up a page, and seemingly ignores whatever I set as its target & action.
self.navigationItem.backBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Cancel"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(foo)] autorelease];
In keeping with other Q&A sessions here on St开发者_JAVA技巧ackOverflow, I've set the backBarButtonItem in the page before the one that uses it. Counterintuitive, but that part works.
self.navigationItem.leftBarButtonItem =
[[[UIBarButtonItem alloc] initWithTitle:@"Cancel"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(foo)] autorelease];
Use left bar button item instead.
精彩评论