0
我已經有我的插入方法以及編輯。但我想知道的是如何識別一個觸摸事件時,只點擊tablview插入?這與提醒應用程序類似,您可以在UITableView中的任何位置觸摸以插入新記錄。點擊時UITABLEVIEW呼叫插入方法
UITableView *tableView = mytableview;
CGPoint tableLocation = [touch locationInView:tableView];
// this one recognises when I edit a record on a UITableview
if([touch.view isKindOfClass:[UITableViewCell class]]) {
return NO;
}
if([touch.view.superview isKindOfClass:[UITableViewCell class]]) {
return NO;
}
if([touch.view.superview.superview isKindOfClass:[UITableViewCell class]]) {
return NO;
}
// this one recognises if I tap on a UITableView
if ([tableView hitTest:tableLocation withEvent:Nil]) {
//differentiate scrolling from tapping to invoke add method
}
else
{
}
也許在UITableView的一個UITapGestureRecognizer? – dklt
非常感謝我以前已經完成了這項工作,如果有任何問題,我只需要尋求替代解決方案。 –
對,也許然後通過visibleCells循環+檢測使用rectForRowAtIndexPath插入到上面或下面的哪個單元格? – dklt