我有UITableViewController并搜索它。然后搜索是ON,想在TableView上创建UIView以“淡化”它。但我也用tableView禁用userInterection。所以问题是,现在我无法识别触摸我的UIview。
- (void) createFade {
UIView *fade = [UIView new];
fade.tag = 1000;
fade.backgroundColor = [UIColor colorWithRed:106.0/255 green:106.0/255 blue:106.0/255 alpha:0.56];
fade.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height);
fade.center = self.view.center;
[self.view addSubview:fade];
[fade bringSubviewToFront:self.view];
UITapGestureRecognizer *headerTapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fadeTapped:)];
[fade addGestureRecognizer:headerTapped];
self.tableView.userInteractionEnabled = NO;
fade.userInteractionEnabled = YES;
}
-(IBAction) fadeTapped:(UITapGestureRecognizer *)gestureRecognizer {
NSLog(@"TUT");
[_searchBar resignFirstResponder];
[UIView animateWithDuration:0.5 animations:^{
_searchBar.alpha = 0;
} completion:^(BOOL finished) {
_searchBar.showsCancelButton = false;
}];
[[self.view viewWithTag:1000] removeFromSuperview];
isSearchUp = NO;
[self.tableView reloadData];
_searchBar.text = @"";
[self setupButtons];
[self setupTitle];
}
答案 0 :(得分:0)
你可以继承UIViewController并在其中使用tableView,因为UITableViewController会添加任何添加到它的视图,UITableViewController使整个屏幕可滚动,所以即使你在任何固定位置添加一个视图也是滚动而无法接收任何动作
tableViewController中的
> self.view equal to tableView itself
在viewController中
> self.view the usual as we know it