但是,我不认为这是一个与代表有关的问题,或者是不被调用的另一个常见原因.在搜索时,包含搜索结果的表视图显示为灰色(即不活动),我相信这是为什么我无法选择任何单元格.
我的想法是,UISearchbar被卡住作为第一响应者,但是我尝试了各种方式来撤销这种状态和/或试图强制表视图成为第一响应者,但是所有这些都有灾难性的结果.
这是我的UItableVIEwController子类的相关代码:
@interface SearchResultstableVIEwController()@property (copy,nonatomic) NSArray *searchResults;@property (strong,nonatomic) UISearchController *searchController;@end@implementation SearchResultstableVIEwController- (NSArray *)searchResults{ // Lazy array instantiation if (!_searchResults) { _searchResults = [[NSArray alloc] init]; } return _searchResults;}- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; [self setSearchController:[[UISearchController alloc] initWithSearchResultsController:nil]]; [[self searchController] setSearchResultsUpdater:self]; [[[self searchController] searchbar] setFrame:CGRectMake(0.0f,0.0f,CGRectGetWIDth([[self tableVIEw] frame]),44.0f)]; [[[self searchController] searchbar] setSearchbarStyle:UISearchbarStyleMinimal]; [[[self searchController] searchbar] setPlaceholder:@"Search Presentations"]; [[[self searchController] searchbar] setDelegate:self]; [[self tableVIEw] settableheaderVIEw:[[self searchController] searchbar]]; [[self tableVIEw] setSeparatorStyle:UItableVIEwCellSeparatorStyleNone]; [[self tableVIEw] setAllowsSelection:YES]; [[self tableVIEw] setAllowsSelectionDuringEditing:YES]; [[self tableVIEw] setDelegate:self]; [[self tableVIEw] setDataSource:self];}- (NSInteger)numberOfSectionsIntableVIEw:(UItableVIEw *)tableVIEw{ return 1;}- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{ return [[self searchResults] count];}- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UItableVIEwCell *cell = [[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:@"Search Results Cell"]; [cell setSelectionStyle:UItableVIEwCellSelectionStyleDefault]; [cell setUserInteractionEnabled:YES]; [[cell textLabel] setEnabled:YES]; FXIPresentation *presentation = nil; presentation = [[self searchResults] objectAtIndex:[indexPath row]]; [[cell textLabel] setText:[[presentation Title] substringFromIndex:3]]; [[cell textLabel] setTextcolor:[UIcolor colorWithRed:(18.0/255.0) green:(52.0/255.0) blue:(88.0/255.0) Alpha:1.0f]]; return cell;}- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // Omitted / Never called}- (voID)updateSearchResultsForSearchController:(UISearchController *)searchController{ [self setSearchResults:nil]; nspredicate *predicate = [nspredicate predicateWithFormat:@"Title contains[c] %@",[[[self searchController] searchbar] text]]; [self setSearchResults:[[self fullResults] filteredArrayUsingPredicate:predicate]]; [[self tableVIEw] reloadData];}@end解决方法 也许是因为您正在搜索的相同视图中显示搜索结果?尝试防止视图变暗
self.searchController.dimsBackgroundDuringPresentation = NO;总结
以上是内存溢出为你收集整理的ios – UISableContController中的UISearchController – 行不可选,表视图是灰色的全部内容,希望文章能够帮你解决ios – UISableContController中的UISearchController – 行不可选,表视图是灰色的所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)