如何控制UISearchDisplayController的表自己的观点?
题
在我的应用程序,当我没过滤我表,当时我在一个小区,其框架的高度增加,以显示一个 UIProgressView
这显示了下载进展情况。
然而,当我过滤器的结果取控制器的数据 UISearchDisplayController
, 细胞在这个过滤表景不行为以同样的方式。
相反,该单元不调整,没有显示取得的进展来看,不会触发下载,和应用程序随后崩溃。
我如何获得控制权的表看法,即被提出时,筛选的结果 UISearchDisplayController
?
编辑
这里是我的 -tableView:didSelectRowAtIndexPath:
法。这是一个比较长,但其要旨是,它工作得很好,当我不搜索。
我想我需要适应这种莫名其妙,这样它可以与任何表查看/牵强的结果控制器,搜索结果的控制器是扔在这。
- (void) tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tv deselectRowAtIndexPath:indexPath animated:YES];
if ([self.searchBar isFirstResponder])
[self.searchBar resignFirstResponder];
MyObject *_myObject = (MyObject *)[self.fetchedResultsController objectAtIndexPath:indexPath];
if (self.isSimulatingFileHierarchy)
{
if ([_myObject isFolder])
{
ObjectsViewController *_objectsViewController = [[ObjectsViewController alloc] initWithNibName:@"ObjectsViewController" bundle:nil];
_objectsViewController.managedObjectContext = self.managedObjectContext;
_objectsViewController.nodeID = self.nodeID;
_objectsViewController.nodeName = self.nodeName;
_objectsViewController.parentObjectKey = [_myObject cleanedKey];
if (self.parentObjectKey)
_objectsViewController.title = [[_myObject cleanedKey] stringByTrimmingPrefix:[self.parentObjectKey stringByAppendingString:@"/"]];
else
_objectsViewController.title = [_myObject cleanedKey];
[self.navigationController pushViewController:_objectsViewController animated:YES];
UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:self.title style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.backBarButtonItem = _backButton;
[_backButton release];
[_objectsViewController release];
}
else {
//
// If we don't have data cached for this object, we add a request for the object's bytes to the objectRequestQueue
//
// 1. We add a progress indicator to the object's cell (we have an indexPath)
// 2. We store the data to the Documents folder
//
// Once we have the data, we push a ViewerViewController subclass that is specific to the object content type
//
if ((!_myObject.isDownloading) && ([_myObject.localPath length] == 0))
{
if ([AwsObject objectContentSupportedForType:[_myObject.contentType intValue]])
{
//
// Start request and redraw row with UIProgressView
//
[self triggerObjectRequestAdditionForObject:_myObject atIndexPath:indexPath];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ObjectsViewObjectRequestUnsupportedTypeAlertViewTitle", @"") message:NSLocalizedString(@"ObjectsViewObjectRequestUnsupportedTypeAlertViewMessage", @"") delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"ObjectsViewObjectRequestUnsupportedTypeAlertViewContinue", @""), nil];
[alert show];
[alert release];
}
}
else if ((_myObject.isDownloading) && ([_myObject.localPath length] == 0))
{
//
// Cancel request and redraw row without progress view
//
[self triggerObjectRequestRemovalForObject:_myObject atIndexPath:indexPath];
}
else if ((!_myObject.isDownloading) && ([_myObject.localPath length] != 0))
{
//
// Launch viewer for supported MIME type
//
switch ([_myObject.contentType intValue]) {
case kObjectContentTypeApplicationMsword: {
[self pushWebViewerViewController:_myObject withTextEncoding:@"UTF-8"];
break;
}
// handle other MIME types here...
}
}
else {
if ([_myObject isFolder]) { }
else {
if ((!_myObject.isDownloading) && ([_myObject.localPath length] == 0))
[self triggerObjectRequestAdditionForObject:_myObject atIndexPath:indexPath];
else if ((_myObject.isDownloading) && ([_myObject.localPath length] == 0))
[self triggerObjectRequestRemovalForObject:_myObject atIndexPath:indexPath];
else if ((!_myObject.isDownloading) && ([_myObject.localPath length] != 0)) {
switch ([_myObject.contentType intValue]) {
case kObjectContentTypeApplicationMsword: {
[self pushWebViewerViewController:_myObject withTextEncoding:@"UTF-8"];
break;
}
// handle other MIME types here...
}
}
}
}
}
}
}
解决方案
在任何的表视图委托方法,可以指定是否与UISearchDisplayController的表视图,通过使用下面的检查工作检测:
if (tableView == self.searchDisplayController.searchResultsTableView) {
// behavior specific to search display controller table view
}
else {
// behavior specific to the original, unfiltered table view
}
其他提示
通常,你会检查发表的看被通过 tableView:didSelectRowAtIndexPath:
等到你搜索显示控制器的"searchResultsTableView"和程序的备用行为,这种情况。
它听起来像是你的问题可能更加复杂。你可以发布的代码 tableView:didSelectRowAtIndexPath:
?
不隶属于 StackOverflow