I am having some trouble passing the search bar text to the popover view. The flow is like this:
- Parent view has a toolbar with a uisearchbar
- Parent view is connected with a segue to another subclassed uiviewcontroller, and displays this as a popover from the searchbar
- The popover viewcontroller uses a tableview to display the data I want filtered (table view is setup and works fine, method that filters the results is setup and works fine).
- Parent view is the delegate of the searchbar and receives the text everytime the search term is changed
How can I pass the search term to the popover? I setup a custom delegate in the parentview with a method that should pass the search term to the delegate method, but that method is not being called in the popover.
*My best guess is that I need to somewhere specify that the popover uses my custom delegate (i.e Declaring ThisView.delegate = self, but this is a problem since the child view is created by a segue)
Here is how the popover is displayed:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"segueSearchResults"]) {
self.searchPopover = [(UIStoryboardPopoverSegue *)segue popoverController];
self.searchPopover.delegate = self;//To avoid confusion, this is the popover's delegate to notify the parent view when it has closed, etc.
}
}
Here is the delegate protocol:
@class VideoViewController;
@protocol VideoViewDelegate <NSObject>
@required
- (void)searchTermChanged:(NSString *)value;
@end
@interface VideoViewController : UIViewController<UIScrollViewDelegate,UISearchBarDelegate,UISearchDisplayDelegate,UIPopoverControllerDelegate>{
__weak id <VideoViewDelegate> delegate;
}
@property (nonatomic, weak) id <VideoViewDelegate> delegate;