2012-01-22 10 views
0

それをどうして解決すればいいのか不思議です。この検索バーはこのように見えます。 enter image description heresearchDisplayControllerWillEnd検索バーのサイズが変更されていません

クリックされたものが上に移動し、検索バーの高さは0,0,320になります。キャンセル]をクリック

enter image description here

、それは、バック33,55,270に検索バーの高さを変更する必要があります。しかし、それはない

enter image description here

searchDisplayControllerDidEndSearchが戻ってサイズを変更していきます、しかし、ユーザーが変更を見ることができた1秒の遅れがあります。任意の身体がなぜsearchDisplayControllerWillEndSearchでアニメーションのサイズを変更できないのですか?

コメントとフィードバックに感謝します。

- (void) searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller 
{ 

    [UIView animateWithDuration:.1 
        animations:^{ 

    controller.searchResultsTableView.frame = frogTableView.frame; 
    searchDisplayController.searchResultsTableView.frame = frogTableView.frame; 

    searchDisplayController.searchBar.frame = CGRectMake(32, 
                 55, 
                 270, 
                 searchDisplayController.searchBar.frame.size.height); 

    searchBar.frame = CGRectMake(32, 
           55, 
           270, 
           searchBar.frame.size.height); 
         frogTableView.frame = CGRectMake(frogTableView.frame.origin.x, 
                  121, 
                  frogTableView.frame.size.width, 
                  frogTableView.frame.size.height); 

         notePad.frame = CGRectMake(notePad.frame.origin.x, 
                45, 
                notePad.frame.size.width, 
                notePad.frame.size.height); 

         searchDisplayController.searchResultsTableView.frame = frogTableView.frame; 
         } 
        completion:^(BOOL finished){ 
         //whatever else you may need to do 

        }]; 
} 
+0

Ooohhh、なぜブロック?一般的にGCDや複雑なネットワーキングのようなものにしか使われません。あなたはそれを酷使しています:P –

+0

だから私はGalaxas0をどうすればいいですか? – Desmond

+1

可能性があります - http://stackoverflow.com/questions/556814/changing-the-size-of-theisearchbar-textfield – rishi

答えて

2

私はUISearchDarをUISearchDisplayControllerで使用し始めてから同じ問題が発生しました。

UIView * searchBarSubview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, MENU_WORK_AREA_WIDTH, SEARCH_BAR_HEIGHT)] ; 
searchBarSubview.autoresizesSubviews = YES; 
searchBarSubview.backgroundColor = [UIColor clearColor]; 

UISearchBar * globalSearchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, MENU_WORK_AREA_WIDTH, SEARCH_BAR_HEIGHT)] autorelease]; 
globalSearchBar.tintColor = [UIColor blackColor]; 
globalSearchBar.delegate = self; 
[globalSearchBar setBackgroundImage:[UIImage alloc]]; 

とsearchDisplayControllerWillEndSearchで代わりに検索バーの表示サイズを変更::私が思いついた解決策は、ビューの検索バーを配置することです(UISearchDisplayController *)コントローラ:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationDuration:0.3]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 

// Slide in to the final destination 
searchBarSubview.frame = CGRectMake(0, 0, MENU_WORK_AREA_WIDTH, SEARCH_BAR_HEIGHT); 

[UIView commitAnimations]; 
関連する問題