The coordinates of the iOS cell are converted to the coordinates of the window, and the position of the bullet frame is under the cell

 The coordinates of the iOS cell are converted to the coordinates of the window.

 

  CGFloat alertViewWith = 200;//宽自己定义
      
//(只有这两句是核心代码)拿到当前cell的frame,转换为window的坐标.
      CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
      CGRect rect = [tableView convertRect:rectInTableView toView:[UIApplication sharedApplication].keyWindow];


//这里是 y + 高
      CGFloat alertViewHight = rect.origin.y + rect.size.height;
      NSLog(@"%@",NSStringFromCGRect(rect));
//最后设置你的弹框frame
      alertView.frame = CGRectMake(weakCell.subTitleTextField.x,alertViewHight, alertViewWith, 200);

Effect picture

Guess you like

Origin blog.csdn.net/ximiaoweilai/article/details/105641658