Skip to content

Commit

Permalink
Remove duplicate setDefaultOptions in UIViewController categories (#5448
Browse files Browse the repository at this point in the history
)

This is already defined in UIViewController+LayoutProtocol and depending 
on the load order will actually prevent the default orders from being 
set
  • Loading branch information
danilobuerger authored and guyca committed Sep 4, 2019
1 parent 7d6ff5d commit 452c4e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 0 additions & 2 deletions lib/ios/UIViewController+RNNOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

@interface UIViewController (RNNOptions)

- (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions;

- (void)rnn_setBackgroundImage:(UIImage *)backgroundImage;

- (void)rnn_setModalPresentationStyle:(UIModalPresentationStyle)modalPresentationStyle;
Expand Down
18 changes: 7 additions & 11 deletions lib/ios/UIViewController+RNNOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@

@implementation UIViewController (RNNOptions)

- (void)setDefaultOptions:(RNNNavigationOptions *)defaultOptions {

}

- (void)rnn_setBackgroundImage:(UIImage *)backgroundImage {
if (backgroundImage) {
UIImageView* backgroundImageView = (self.view.subviews.count > 0) ? self.view.subviews[0] : nil;
if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
[self.view insertSubview:backgroundImageView atIndex:0];
}

backgroundImageView.layer.masksToBounds = YES;
backgroundImageView.image = backgroundImage;
[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
Expand All @@ -36,7 +32,7 @@ - (void)rnn_setModalTransitionStyle:(UIModalTransitionStyle)modalTransitionStyle
self.modalTransitionStyle = modalTransitionStyle;
}

- (void)rnn_setSearchBarWithPlaceholder:(NSString *)placeholder
- (void)rnn_setSearchBarWithPlaceholder:(NSString *)placeholder
hideNavBarOnFocusSearchBar:(BOOL)hideNavBarOnFocusSearchBar {
if (@available(iOS 11.0, *)) {
if (!self.navigationItem.searchController) {
Expand All @@ -52,7 +48,7 @@ - (void)rnn_setSearchBarWithPlaceholder:(NSString *)placeholder
search.hidesNavigationBarDuringPresentation = hideNavBarOnFocusSearchBar;
self.navigationItem.searchController = search;
[self.navigationItem setHidesSearchBarWhenScrolling:NO];

// Fixes #3450, otherwise, UIKit will infer the presentation context to be the root most view controller
self.definesPresentationContext = YES;
}
Expand Down Expand Up @@ -161,7 +157,7 @@ - (BOOL)isModal {
return YES;
if([[[self tabBarController] presentingViewController] isKindOfClass:[UITabBarController class]])
return YES;

return NO;
}

Expand All @@ -182,12 +178,12 @@ - (void)rnn_setBackButtonIcon:(UIImage *)icon withColor:(UIColor *)color title:(
[self.navigationController.navigationBar setBackIndicatorImage:[UIImage new]];
[self.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[UIImage new]];
}

UIViewController *lastViewControllerInStack = self.navigationController.viewControllers.count > 1 ? self.navigationController.viewControllers[self.navigationController.viewControllers.count - 2] : self.navigationController.topViewController;

backItem.title = title ? title : lastViewControllerInStack.navigationItem.title;
backItem.tintColor = color;

lastViewControllerInStack.navigationItem.backBarButtonItem = backItem;
}

Expand Down

0 comments on commit 452c4e6

Please sign in to comment.