I am trying to display a searchbar on top of the UITableView of the Master screen of the Master/Detail view. Using the storyboard, the search bar cannot be placed directly under the header/banner (that says "Master") unless I have the number of prototype cells set to 0. However, I cannot make it appear regardless of where it is displayed once the table becomes populated. I have put it in a view that sits on top of the table (SplashView), and attempted to make it visable/etc and put the searchbar view on top of the table view, but nothin'.
I have to believe it is possible, but I don't know where I have failed.
Also, it appears that changing the x,y coordinates is not allowed in this case. Is the Master/Detail special in some way?
Any hints would be greatly appreciated. Please and Thank you! :bp:
xcode 4.6.2
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
@interface EGMasterViewController : UITableViewController <NSFetchedResultsControllerDelegate, UISearchDisplayDelegate, UISearchBarDelegate>
@property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
@property (weak, nonatomic) IBOutlet UILabel *loadingLabel;
@property (strong, nonatomic) IBOutlet UIPanGestureRecognizer *panGestureRecognizer;
- (IBAction)panGestureDetected:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *SplashView;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@end
and:
- (void) searchForEvent: (id) sender
{
UIView * vptr = [self view];
[self.SplashView setHidden:NO];
[self.searchBar setHidden:NO];
[self.spinner setHidden:YES];
[self.loadingLabel setHidden:YES];
[vptr bringSubviewToFront:self.searchBar];
}
Just add an UISearchDisplayController into your storyboard, connect your view controller with it, and then add the search display's searchbar into the tableview header view at runtime. Something like:
- (void)viewDidLoad{
[self.tableView setTableHeaderView:self.searchDisplayController.searchBar];
[super viewDidLoad];
}