开发者

backButtonItem stuck with default behavior

开发者 https://www.devze.com 2023-03-27 04:00 出处:网络
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'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

精彩评论

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