私は a を持っています-- aと aを含むUIView
それを呼び出します。つまり、サブビューです。これらはforに追加されます。百聞は一見に如かず。HomeView
UITableView
UISearchBar
viewDidLoad
HomeView
これらのスクリーンショットからわかるようにUITableView
、 が表示されると、 の最初の項目が非UISearchBar
表示になります。関連するコードは次のとおりです。
- (void) viewDidLoad
self.table_view = [UITableView.alloc.initWithFrame: self.view.bounds style:UITableViewStylePlain];
self.table_view.bounds.origin.y += 44;
self.table_view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// ^^^ This is the code I believe is one source of my problem
// Triggered when search button in nav bar is pressed
// code to calculate delta here
// Here's how the view is animated. The search bar frame
// is dropped down (works), and ideally, the tableview
// drops down exactly the same amount at the same time.
// If the action is to hide, then the inverse happens
// because +delta+ will have been calculated as a
// negative number above.
[UIView animateWithDuration: 0.7
delay: 0.0
options: UIViewAnimationOptionCurveEaseIn
animations:^ {
self.searchBar.frame = CGRectOffset(@searchBar.frame, 0.0, delta);
}
completion:^(BOOL finished){
self.searchBarVisible = !self.searchBarVisible
self.searchBar.hidden = !self.searchBarVisible
edgeInsets = UIEdgeInsetsMake(0.0f, self.searchBarVisible ? delta : 0.0f, 0.0f, 0.0f)
[tableView setContentInset: edgeInsets]
}
];
実際に何が起こるかというと、検索ボタンを押すと検索バーが期待どおりに下にスライドし、次にボタンを押すと上にスライドします。ただし、テーブル ビューは調整されません。
私が知る限りの問題はviewDidLoad
、 では囲みHomeView
がレンダリングされていないため、サイズがまだ不明であることです。画面のサイズを取得してそれを使用することはできますが、自動サイズ変更マスクの方が優れていると思いましたよね?
これには明らかな欠陥がありますか?検索バーと同時にテーブルビューをアニメーション化する方法はありますか?
ありがとう