2012-01-22 3 views
0

왜 그런지 궁금하고 해결할 필요가 있습니다. 이 검색 창은 이렇게 보입니다. enter image description heresearchDisplayControllerWillEnd 검색 창의 크기를 조정하지 않음

클릭하면 위쪽으로 이동하여 검색 창 높이가 0,0,320입니다. 이 33,55,270, 검색 창 높이로 다시 크기를 조정해야 취소를 클릭

enter image description here

. 하지만 그렇지 않은

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

UISearchDisplayController를 사용하여 UISearchBar를 사용하기 시작한 후에도 동일한 문제가있었습니다.

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]; 
관련 문제