相关api
- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;
- (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;
- (CGRect)convertRect:(CGRect)rect toView:(UIView *)view;
- (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view;
使用
CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
CGRect rectInSuperview = [tableView convertRect:rectInTableView toView:[tableView superview]];
举个荔枝
CGRect rectInTableView = [self.detailTable rectForRowAtIndexPath:_mapheigt];
CGRect rectInSuperview = [self.detailTable convertRect:rectInTableView toView:[self.detailTable superview]];
NSLog(@"%@",NSStringFromCGRect(rectInSuperview));
_mapView = [[BMKMapView alloc] initWithFrame:CGRectMake(0,rectInSuperview.origin.y+48.5+22, kSCREEN_WIDTH, kSCREEN_HEIGHT - (rectInSuperview.origin.y+48.5+22))];
需要注意的是:
图中 箭头所指的高度 是你需要定位的最后一个cell的高度