开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜