【发布时间】:2016-10-04 14:58:05
【问题描述】:
我将在KGModal 中展示我的tableViewController。
在我的viewDidLoad 中,我添加了以下几个属性来管理 tableView:
[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];
更新
通过遵循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;
【问题讨论】:
-
@HannahLouisaCarney 查看我更新的问题
-
你能把你的项目贴在这里
-
@Anbu.Karthik 我该怎么做?
-
将您的项目附加到下拉框中并提供链接
标签: ios objective-c uitableview uisearchcontroller