2012-12-10 2 views
2

현재 검색 단추에 취소 단추 항목이 표시되지 않도록 다음 방법을 사용하고 있습니다. 대신 UIButton을 사용하고 싶습니다.UISearchBar에서 취소 단추를 재정의하는 방법

문제는 현재 취소 버튼이 내장되어 있다는 것입니다. 어떤 도움

- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller 
{ 
    controller.searchBar.showsCancelButton = NO; 
} 

감사

+0

당신이 programaticaly 또는를 통해 검색 창을 추가하고이 링크를 통해 이동하여 버튼을 취소하여 숨길 수 있습니다 XIB? –

답변

3

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar 
{ 
    [searchBar setShowsCancelButton:NO animated:YES]; 
} 
0
for (UIView *possibleButton in searchBar.subviews) 
{ 
    if ([possibleButton isKindOfClass:[UIButton class]]) 
    { 
     UIButton *cancelButton = (UIButton*)possibleButton; 
     cancelButton.enabled = YES; 
     break; 
    }  
} 

하나 UISearchBar disable auto disable of cancel button

관련 문제