我提出我tableViewController
在KGModal。 在我viewDidLoad
我已經添加了這幾個屬性來管理的tableView:編輯時UISearchController變動幅度開始
[self setupSearchController];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.edgesForExtendedLayout = UIRectEdgeNone;
self.definesPresentationContext = NO;
self.view.clipsToBounds = YES;
而setupSearchController是
-(void)setupSearchController
{
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
// self.searchController.searchBar.scopeButtonTitles = @[NSLocalizedString(@"ScopeButtonCountry",@"Country"), NSLocalizedString(@"ScopeButtonCapital",@"Capital")];
// self.searchController.searchBar.clipsToBounds = YES;
self.searchController.searchBar.delegate = self;
}
現在,當我運行程序的時候,告訴我searchController爲
這很好,我正在尋找。但只要它成爲第一個響應者,就會發生這種情況:
通過取消它使其返回到它在第一張圖片中的位置。我的問題是如何讓它保持在KGModal的框架內。凡爲我叫它爲
CPTSearchTableViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"CPTSearchTVC"];
ivc.view.frame = CGRectMake(0, 0, CGRectGetWidth([[UIScreen mainScreen] bounds]) - 40, CGRectGetHeight([[UIScreen mainScreen] bounds]) - 80);
[[KGModal sharedInstance] setCloseButtonType:KGModalCloseButtonTypeRight];
[[KGModal sharedInstance] showWithContentViewController:ivc andAnimated:YES];
[[KGModal sharedInstance] setTapOutsideToDismiss:YES];
[[KGModal sharedInstance] setModalBackgroundColor:[UIColor clearColor]];
[[KGModal sharedInstance] setBackgroundDisplayStyle:KGModalBackgroundDisplayStyleSolid];
UPDATE
通過以下給出here的解決方案,我已經能夠保持它的高度內的一個而不是來看寬度。
我剛剛更新在viewDidLoad中的代碼爲
[self setupSearchController];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
self.tableView.tableHeaderView = self.searchController.searchBar;
self.edgesForExtendedLayout = UIRectEdgeNone;
self.definesPresentationContext = YES;
self.extendedLayoutIncludesOpaqueBars = YES;
http://stackoverflow.com/questions/26222671/uisearchcontroller-searchbar-in-tableheaderview-animating-out-of-the-screen?rq=1你試圖回答這些問題? –
@HannahLouisaCarney看到我更新的問題 –
您可以將您的projct這裏 –