@@ -41,6 +41,7 @@ @interface BlogListViewController () <UIViewControllerRestoration>
4141@property (nonatomic , strong ) IBOutlet NSLayoutConstraint *searchWrapperViewHeightConstraint;
4242@property (nonatomic , weak ) UIAlertController *addSiteAlertController;
4343@property (nonatomic , strong ) UIBarButtonItem *addSiteButton;
44+ @property (nonatomic , strong ) UIBarButtonItem *searchButton;
4445
4546@property (nonatomic ) NSDate *firstHide;
4647@property (nonatomic ) NSInteger hideCount;
@@ -82,11 +83,15 @@ - (void)configureNavigationBar
8283 self.addSiteButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd
8384 target: self
8485 action: @selector (addSite )];
85- UIBarButtonItem *searchButton = [[UIBarButtonItem alloc ] initWithImage: [UIImage imageNamed: @" icon-post-search" ]
86- style: UIBarButtonItemStylePlain
87- target: self
88- action: @selector (toggleSearch )];
89- [self .navigationItem setRightBarButtonItems: @[self .addSiteButton, searchButton]];
86+
87+ self.searchButton = [[UIBarButtonItem alloc ] initWithImage: [UIImage imageNamed: @" icon-post-search" ]
88+ style: UIBarButtonItemStylePlain
89+ target: self
90+ action: @selector (toggleSearch )];
91+
92+ [self updateSearchButton ];
93+
94+ self.navigationItem .title = NSLocalizedString(@" My Sites" , @" " );
9095}
9196
9297- (NSString *)modelIdentifierForElementAtIndexPath : (NSIndexPath *)indexPath inView : (UIView *)view
@@ -232,7 +237,10 @@ - (void)updateSearchButton
232237 NSManagedObjectContext *context = [[ContextManager sharedInstance ] mainContext ];
233238 BlogService *blogService = [[BlogService alloc ] initWithManagedObjectContext: context];
234239 if ([blogService blogCountForAllAccounts ] <= 1 ) {
235- self.navigationItem .rightBarButtonItem = nil ;
240+ // Hide the search button if there's only one blog
241+ self.navigationItem .rightBarButtonItems = @[ self .addSiteButton ];
242+ } else {
243+ self.navigationItem .rightBarButtonItems = @[ self .addSiteButton, self .searchButton ];
236244 }
237245}
238246
0 commit comments