On Mar 12, 2012, at 18:57 , Roland King wrote: > If you really hate that, not sure what you can do. What was your idea for > subclassing UINavigationController? I didn't instantly see a place to hook in > without messing with the navigationBar delegate, something the documentation > tells you not to do (although I'd probably try that anyway).
My subclass implements one method, the UINavigationBar delegate method: - (BOOL) navigationBar: (UINavigationBar*) inNavigationBar shouldPopItem: (UINavigationItem*) inItem { bool shouldPop = true; UIViewController* vc = self.topViewController; if ([vc respondsToSelector: @selector(navigationControllerShouldPop:)]) { shouldPop = [vc performSelector: @selector(navigationControllerShouldPop:) withObject: self]; } if (shouldPop) { // UINavigationController doesn't declare it's a delegate, so we // have to do this ugliness… BOOL (*f)(id, SEL, ...) = [UINavigationController instanceMethodForSelector: _cmd]; shouldPop = f(self, _cmd, inNavigationBar, inItem); } return shouldPop; } The call to + instanceMethodForSelector: is required because UINavigationController doesn't actually declare it's a delegate, and I can't just call super. Any top view controller that implements -navigationControllerShouldPop: will get called. This seems to work. I may end up changing the buttons after all, but this'll do for now. -- Rick _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com