【问题标题】:UISearchBar with a custom UITableView带有自定义 UITableView 的 UISearchBar
【发布时间】:2012-11-12 18:49:25
【问题描述】:

我希望以下内容在 iOS4 中工作:

-(void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
    controller.searchResultsTableView.allowsMultipleSelectionDuringEditing = YES;
}

但是,UITableView 不支持它。如何更改 searchResultsTableView 使其使用 UDTableView (https://github.com/ud7/UDTableView-allowsMultipleSelection) 而不是 UITableView

【问题讨论】:

  • 试着让你的班级实现这个协议:UISearchDisplayDelegate

标签: ios uitableview uisearchbar


【解决方案1】:

我没有设法使用子类,但是在没有 UDTableView 的情况下,我有多个部分在搜索模式下工作:

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

    if ([controller.searchResultsTableView respondsToSelector:@selector(allowsMultipleSelectionDuringEditing)]) {
        controller.searchResultsTableView.allowsMultipleSelectionDuringEditing = YES;
    }
    else {
        controller.searchResultsTableView.allowsSelectionDuringEditing = YES;
    }
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellAccessoryCheckmark;
}

【讨论】:

    猜你喜欢
    • 2014-08-13
    • 1970-01-01
    • 2023-03-18
    • 2012-12-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多