我正在尝试获取 FSCalendarView 中选定单元格的位置。(FSCalendar 库)。虽然我从屏幕获取位置,但它不是一个完美的位置,因为我想从那个日期单元格显示弹出窗口。
我做了这样的事情,以获得触摸位置,
#pragma mark - View Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oneFingerTwoTaps)];
tapGesture.delegate=self;
// Set required taps and number of touches
[tapGesture setNumberOfTapsRequired:1];
[tapGesture setNumberOfTouchesRequired:1];
[[self view] addGestureRecognizer:tapGesture];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
CGPoint pointOnScreen = [touch locationInView:nil];
NSLog(@"Point - %f, %f", pointOnScreen.x, pointOnScreen.y);
NSLog(@"Touch");
touchFrame = CGRectMake(pointOnScreen.x, pointOnScreen.y-120, 0, 0);
return NO; // handle the touch
}
这就是我能够从这段代码中实现的,
但是当我在日期上方触摸 lil 时,我得到了与该触摸相对应的位置,并且弹出窗口没有出现在正确的位置。它看起来像这样,
有什么方法可以得到正确的日期位置。任何类型的帮助都将是可观的。