2013-01-04 52 views
0

searchBar:shouldChangeTextInRange:replacementText從未調用過。該代表被定義,方法 - searchBarShouldBeginEditing:searchBarTextDidBeginEditing:工作正常,但shouldChangeTextInRange未被調用。我發現,當值存取在使用alertview後,我的方法嘗試使用searchbar..the shouldChangeTextInRange叫...但在此之前沒有searchBar:shouldChangeTextInRange:replacementText不叫

-(void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar { 
    } 

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar 
{ 
return YES; 
} 

-(BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text 
{ 
return YES; 
} 


-(BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar { 
return YES; 
} 

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { 

    } 
+0

我做了一個測試,並把alertview視圖中沒有加載...釷searchBar工作...但我不想alertView:S – Ladessa

回答

0

我的appDelegate,已經錯過下面的代碼applicationDidFinishLauching

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
[self.window makeKeyAndVisible]; 

現在的搜索欄工作正常!