sectionHeaderTapped
應具有以下特徵之一的方法:
- (void)sectionHeaderTapped:(UITapGestureRecognizer *)sender;
- (void)sectionHeaderTapped;
你必須弄清楚,用水龍頭的座標拍了拍細胞。
-(void)sectionHeaderTapped:(UITapGestureRecognizer *)gestureRecognizer
{
CGPoint tapLocation = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *tapIndexPath = [self.tableView indexPathForRowAtPoint:tapLocation];
UITableViewCell* tappedCell = [self.tableView cellForRowAtIndexPath:tapIndexPath];
}
您可以使用該方法可能得到的節頭。但是,將不同的手勢識別器附加到每個節標題可能會更容易。
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
// ...
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sectionHeaderTapped:)];
[headerView addGestureRecognizer:tapGesture];
return headerView;
}
然後
-(void)sectionHeaderTapped:(UITapGestureRecognizer *)gestureRecognizer
{
UIView *headerView = gestureRecognizer.view;
// ...
}
來源
2012-03-16 10:28:20
sch
是啊,我已經用不同的手勢每個部分,並不是最好的方法,但比較容易的方式...感謝 – 2012-03-16 12:40:32
省長回答....感謝.. – 2015-04-01 11:32:36