Skip to content
This repository

Hotfix openURLFromButton: crash #463

Closed
wants to merge 1 commit into from

1 participant

Jeff Verkoeyen
Jeff Verkoeyen

When using openURLFromButton: we will likely be calling this from a
UIBarButtonItem object, which isn't a descendant of the UIView class.

We return the global navigator because there's no simple way
to determine the class from the bar button item. This is a
trade-off of ease-of-use over proper functionality here. If you want
to get a UIBarButtonItem to open a specific navigator, handle the
button tapped method yourself and get the correct navigator.

Jeff Verkoeyen [UINavigator] Check the view class in navigatorForView.
When using openURLFromButton: we will likely be calling this from a
UIBarButtonItem object, which isn't a descendant of the UIView class.

We return the global navigator because there's no simple way
to determine the class from the bar button item. This is a
trade-off of ease-of-use over proper functionality here. If you want
to get a UIBarButtonItem to open a specific navigator, handle the
button tapped method yourself and get the correct navigator.
1262670
Jeff Verkoeyen

Added note to the header documenting this special case.

Jeff Verkoeyen

Merge branch 'hotfix-openURLFromButton-crash'

Closed by 2ce7b12.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 10, 2011
Jeff Verkoeyen [UINavigator] Check the view class in navigatorForView.
When using openURLFromButton: we will likely be calling this from a
UIBarButtonItem object, which isn't a descendant of the UIView class.

We return the global navigator because there's no simple way
to determine the class from the bar button item. This is a
trade-off of ease-of-use over proper functionality here. If you want
to get a UIBarButtonItem to open a specific navigator, handle the
button tapped method yourself and get the correct navigator.
1262670
This page is out of date. Refresh to see the latest.
6  src/Three20UINavigator/Headers/TTBaseNavigator.h
@@ -164,6 +164,12 @@
164 164
  * with the top-most controller that contains this view that /isn't/ the container.
165 165
  * If getNavigatorForController: returns a navigator, this navigator is returned.
166 166
  * Otherwise, the global navigator is returned.
  167
+ *
  168
+ * If the given view is not, in fact, a view, which is the case if a UIBarButtonItem is passed,
  169
+ * returns the global navigator via [TTBaseNavigator globalNavigator].
  170
+ *
  171
+ * If you need to use a specific navigator for UIBarButtonItem, handle the button tap
  172
+ * yourself and use navigatorForView: on an actual view in the controller.
167 173
  */
168 174
 + (TTBaseNavigator*)navigatorForView:(UIView*)view;
169 175
 
6  src/Three20UINavigator/Sources/TTBaseNavigator.m
@@ -127,6 +127,12 @@ + (void)setGlobalNavigator:(TTBaseNavigator*)navigator {
127 127
 
128 128
 ///////////////////////////////////////////////////////////////////////////////////////////////////
129 129
 + (TTBaseNavigator*)navigatorForView:(UIView*)view {
  130
+  // If this is called with a UIBarButtonItem, we can't traverse a view hierarchy to find the
  131
+  // navigator, return the global navigator as a fallback.
  132
+  if (![view isKindOfClass:[UIView class]]) {
  133
+    return [TTBaseNavigator globalNavigator];
  134
+  }
  135
+
130 136
   id<TTNavigatorRootContainer>  container = nil;
131 137
   UIViewController*             controller = nil;      // The iterator.
132 138
   UIViewController*             childController = nil; // The last iterated controller.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.