我不明白爲什麼這UIButton
不工作在我的UITableView
的標題。它出現在那裏,但觸摸不起作用。UIButton不工作在我的UITableView的標題
NSLog語句不會被觸發。這幾乎就像是在另一個視圖或其他視圖之下,以便您可以看到它,但是新聞行爲不起作用。
感謝這個
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *sectionHeader = [[UILabel alloc] initWithFrame:CGRectNull];
sectionHeader.backgroundColor = [UIColor clearColor];
[sectionHeader addSubview:self.topMapView];
// add map launch button
mapLaunchButton = [UIButton buttonWithType:UIButtonTypeCustom];
[mapLaunchButton addTarget:self
action:@selector(mapButtonTouch:)
forControlEvents:UIControlEventTouchDown];
[mapLaunchButton setTitle:@"ggggggg" forState:UIControlStateNormal];
mapLaunchButton.frame = CGRectMake(0, 0, 300, 90);
mapLaunchButton.backgroundColor = [UIColor redColor];
[sectionHeader addSubview:mapLaunchButton];
// [sectionHeader bringSubviewToFront:mapLaunchButton];
self.tableView.tableHeaderView = sectionHeader;
return sectionHeader;
}
- (void)mapButtonTouch:(id)sender {
NSLog(@"map button was touched");
}
做你找到了解決辦法? –
在我的情況下,包含uibutton的視圖禁用了userInteraction tick。 – jonypz