在hitTest上找到一个圆角的UIButton:withEvent:

时间:2016-03-08 14:34:08

标签: ios objective-c iphone cocoa-touch uiscrollview

我有一个mapView(GMSMapView,但它并不重要),而UIScrollView上面有UITableView个对象作为子视图。

我使用hitTest: withEvent:的{​​{1}}方法检测用户点击的位置:

UIScrollView

现在我还添加了一个按钮(//Creating "comparePoint"(CGPoint) CGPoint comparePoint; //Creating "screenBottom"(CGFloat) - the bottom of the scrollView (Y coordinate) CGFloat screenBottom=CGRectGetMaxY(self.frame); //If "allCellsHeight"(CGFloat) is smaller than 44*4 (there is less than 4 cells) if (self.allCellsHeight<=44*4) { //"comparePoint""comparePoint"(CGPoint)'s Y coordinate = "point"(CGPoint)'s Y coordinate-screenBottom+"allCellsHeight" ("allCellsHeight" is the beginning height of the tableView) comparePoint=CGPointMake(point.x, point.y-screenBottom+self.allCellsHeight); }else{ //"comparePoint"(CGPoint)'s Y coordinate = "point"(CGPoint)'s Y coordinate-screenBottom+154 (154 is the beginning height of the tableView) comparePoint=CGPointMake(point.x, point.y-CGRectGetMaxY(self.frame)+154); } //If "comparePoint"(CGPoint) was bigger than 0 (the user tapped on the map) if (comparePoint.y<0) { return nil; } //If "comparePoint"(CGPoint) was smaller than 0 (the user tapped on the tableView) return [super hitTest:point withEvent:event]; )作为UIButton对象的子视图,我不知道如何检测用户是否录制了按钮或在mapView / tableView上。

有人知道我该如何检测到它?

谢谢!

0 个答案:

没有答案