Ios 我想要所选DateCell在FSCalendarVIew中的位置。如何获取?

Ios 我想要所选DateCell在FSCalendarVIew中的位置。如何获取?,ios,objective-c,fscalendar,Ios,Objective C,Fscalendar,我正在尝试获取FSCalendarView中所选单元格的位置。日历库。虽然我从屏幕上得到了位置,但这并不是一个完美的位置,因为我想显示那个日期单元格中的弹出窗口 我做过类似的事情,为了接触位置 #pragma mark - View Lifecycle - (void)viewDidLoad { [super viewDidLoad]; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTar

我正在尝试获取FSCalendarView中所选单元格的位置。日历库。虽然我从屏幕上得到了位置,但这并不是一个完美的位置,因为我想显示那个日期单元格中的弹出窗口

我做过类似的事情,为了接触位置

#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 bit obove日期时,我会得到与该触摸对应的位置,弹出窗口不会出现在正确的位置。它看起来像这样


有什么方法可以得到正确的日期位置吗。任何类型的帮助都是值得的

看起来您可以使用委托方法
calendar:Did选择Date:atMonthPosition:然后使用calendar:cellForDate:atMonthPosition:获取单元格。然后,您可以使用cell.frame获得位置。

在使用了所有可用于FSCalendar的方法后找到了解决方案

对于那些有这些要求的人, 有一个方法-CGRectframeForDate:NSDate*date;它返回所选日期的CGRect,从这个rect中,我们可以找到中心

- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date {
touchFrame = [calendarView frameForDate:date];
CGPoint mypoint = CGPointMake(touchFrame.origin.x + (touchFrame.size.width / 2), touchFrame.origin.y + (touchFrame.size.height / 2));

touchFrame.origin = mypoint;
touchFrame.origin.y = touchFrame.origin.y - 120;
touchFrame.size.height = 0;
touchFrame.size.width = 0;
}