UISearchbar vanishes when in UIScrollView

Viewed 596

I seem to be having an issue with the UISearchbar in iOS 7 vanishing in two scenarios. First the controller is fairly simple it has a nib which contains a scrollview which has in it the uisearch bar and some content. The ui search bar is at the top of the scrollview. So when I scroll the scrollview so the uisearchbar is longer visible and I exit and reneter the controller the uisearch bar is longer visible. Clicking the region makes it appear again. The uisearchbar also vanishes when I double tap it quickly. This controller worked fine is iOS 6 these issues are only happening now that I am building for ios 7

Edit

Investigating the double tap issue causing the uisearchbar to disappear. It seems that the uisearch bar when double tapped quickly is removing the uisearchbar from the view hierarchy when displaying it but never readding it back when it has been dismissed. So I can workaround that by doing

- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
    // workaround for bug in ios 7 were quickly double tapping uisearchbar (e.g it         appears and get dismissed quickly)
    // does not re add the uisearch bar to the correct view.
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
        UIView *parentView = [self.scrollView.subviews objectAtIndex:0];
        [parentView addSubview:self.searchDisplayController.searchBar];
    }
    return;
}
1 Answers
Related