有人知道如何在单击搜索栏后过度调整变暗黑色的大小吗?
我在单击取消时遇到问题,tableview 将扩展然后动画消失。
我用它来调整结果 TableView 的大小。
-(void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
tableView.frame =fTableView.frame;//CGRectMake(26, 100, 280, 310); //fTableView.frame;
tableView.backgroundColor = [UIColor colorWithRed:243.0/255.0 green:236.0/255.0 blue:212.0/255.0 alpha:1];
}
当点击搜索栏时,灰色覆盖层是完整的,而不是我定义的大小。
当点击取消按钮时, View 将展开。
最佳答案
为了移动变暗的覆盖框架,我结合了几个答案。
1: 覆盖 UISearchDisplayController 类
@interface MySearchController : UISearchDisplayController
2:覆盖setActive函数
- (void)setActive:(BOOL)visible animated:(BOOL)animated
{
[super setActive: visible animated: animated];
//move the dimming part down
for (UIView *subview in self.searchContentsController.view.subviews) {
//NSLog(@"%@", NSStringFromClass([subview class]));
if ([subview isKindOfClass:NSClassFromString(@"UISearchDisplayControllerContainerView")])
{
CGRect frame = subview.frame;
frame.origin.y += 10;
subview.frame = frame;
}
}
}
3: 将 xib/storyboard 搜索显示 Controller 从 UISearchDisplayController 更改为 我的搜索 Controller
关于iphone - 调整 UISearchDisplayController 变暗的黑色覆盖层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7989273/