我有一个UITableView。我在tableview旁边有一个像箭头一样的图像。以编程方式选择一个UITableViewCell,如果它包含cgrect
我必须检查箭头是否与特定单元格相交,以便我可以以编程方式选择该单元格。我该怎么做呢?
我没有在单元格/行的选择类型有问题,但有问题检测箭头是否在特定的行上。
我写了这个代码,但不工作:
NSArray *paths = [tableView indexPathsForVisibleRows];
for (NSIndexPath *path in paths)
{
CGRect myRect = [tableView rectForRowAtIndexPath:indexPath];
CGRect myRect1 = CGRectMake(-12, 234, 55, 52);
if (CGRectIntersectsRect(myRect1, myRect))
{
// Also tried [tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
cell.selected = YES;
NSLog(@"\n \n \n myrect = %@ myrect1 = %@ , index = %@ \n \n ", NSStringFromCGRect(myRect),NSStringFromCGRect(myRect1), indexPath);
}
else
{
cell.selected = NO;
}
}
图片显示我想要实现,而不是什么什么存在的。
尝试调用“didSelectRowAtIndexPath方法:”编程。 – George 2013-02-27 10:44:48
做了..不起作用... – 2013-02-27 10:47:38
可以请你显示你在'didSelectRowAtIndexPath'中的代码吗?并且在那里放置一个断点以确保它被调用。 – George 2013-02-27 10:51:32