Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to animate correctly UISearchbar within a custom view with a header view and a UITableview?
    primarykey
    data
    text
    <p>I have a custom UIViewController inited from a nib file with the following view hierarchy:</p> <p><img src="https://i.stack.imgur.com/F0orn.png" alt="Nib"></p> <p>...where on the left side orange area is a "header view" with two UIButtons and an UILabel at the center and blue area is an UITableView; all under a single UIView.</p> <p>At run–time this would render more or less like below:</p> <p><img src="https://i.stack.imgur.com/5LVFw.png" alt="Render"></p> <p>At this point, whenever user will tap on the search bar, I would expect hiding both navigation bar and header view with search bar moved to the top of the window.</p> <p>However this isn't the case, because navigation bar will automatically will get out of the window and the header view will move to top, but still will stay in the scene; rest will stick to their original places.</p> <p>At this point I had to add the following code in order to move header view out of the window:</p> <pre><code>- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.2]; CGRect frame = self.headerView.frame; frame.origin.y -= frame.size.height; self.headerView.frame = frame; [UIView commitAnimations]; } </code></pre> <p>which will result to:</p> <p><img src="https://i.stack.imgur.com/r2uxh.png" alt="Search"></p> <p>... As you may have already noticed header view will move just fine, but the search bar will stick to its original position.</p> <p>I tried to reposition both <code>self.view</code> or search table view, but no luck there.</p> <p>What should I do? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload