Objective c 如何将视图置于UIView层次结构的顶部

Objective c 如何将视图置于UIView层次结构的顶部,objective-c,uitableview,uiview,Objective C,Uitableview,Uiview,我的应用程序目前有一个搜索栏,并生成从搜索栏下拉的结果的持有者视图。但是,ResultContainerView落后于我的其他视图。我想知道如何将搜索栏容器视图置于UIView层次结构的顶部。我尝试使用[super-bringsubview-tofront:\u searchResultsHolderView]; 但这不起作用。这是我点击搜索栏时的方法 - (void)_expandSearchResults { CCLogVerbose (@""); _searchResult

我的应用程序目前有一个搜索栏,并生成从搜索栏下拉的结果的持有者视图。但是,ResultContainerView落后于我的其他视图。我想知道如何将搜索栏容器视图置于UIView层次结构的顶部。我尝试使用
[super-bringsubview-tofront:\u searchResultsHolderView];
但这不起作用。这是我点击搜索栏时的方法

- (void)_expandSearchResults
{
    CCLogVerbose (@"");
    _searchResultsHolderView.alpha = 0.0;
    _searchResultsHolderView.hidden = NO;
    [_searchResultsHolderView setFrameHeight:10];
    [UIView beginAnimations:@"expandSearchResults" context:nil];
    [UIView setAnimationDuration:kAnimationDuration_SearchResults];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector (searchAnimationDidStop:finished:context:)];
    _searchResultsHolderView.alpha = 1.0;
    [_searchResultsHolderView setFrameHeight:_searchResultsHt];
    [super bringSubviewToFront:_searchResultsHolderView];

    [UIView commitAnimations];  // start animation
}
这是我的重载数据方法:

- (void)_reloadSearchResults:(NSString *)searchS
{
    CCLogVerbose (@"");
    if ([searchS length] == 0) {
        _searchResults = nil;
        [_searchResultsTableView reloadData];
        return;
    }

    NSAssert (self.patientService != nil, @"The Patient Service is invalid");
    [self.patientService searchPatients:searchS
        expandType:AllPatientExpansions
        success:^(NSArray *list) {
          _searchResults = list;
          [_searchResultsTableView reloadData];
        }
        failure:^(NSError *error) {
          CCLogDebug (@"Failed: %@", error);
        }];
}
首先,您需要将
self
放在堆栈的顶部。之后,您可以调用
将Subview带到前台
,并将您的
\u searchResultsHolderView
带到前台

[self.superview bringSubviewToFront:self];
    [self bringSubviewToFront:_searchResultsHolderView];