From d1255bf27b967236c79fc5d72e43e0197cccb783 Mon Sep 17 00:00:00 2001 From: nakanomi Date: Sun, 29 Jul 2012 17:57:13 +0900 Subject: [PATCH] Fixes bug crash when UIViewController allocated and pushViewController it in delegate.didSelectDate. --- src/TapkuLibrary/TKCalendarMonthView.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/TapkuLibrary/TKCalendarMonthView.m b/src/TapkuLibrary/TKCalendarMonthView.m index a604384a..f7d87ec2 100644 --- a/src/TapkuLibrary/TKCalendarMonthView.m +++ b/src/TapkuLibrary/TKCalendarMonthView.m @@ -487,6 +487,14 @@ - (NSDate*) dateSelected{ - (void) reactToTouch:(UITouch*)touch down:(BOOL)down{ CGPoint p = [touch locationInView:self]; + /* + When a UIViewController allocated and pushViewController it in delegate.- (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)date. + p.x is over self.bounds.size.width(a cause -- unknown). + And column becomes 7 or more. + It is if it is the 4th [ or more ] row, App will crash (e.g. select 2012/07/29). + So I added check range of p.x. + */ + if(p.x > self.bounds.size.width || p.x < 0) return; if(p.y > self.bounds.size.height || p.y < 0) return; int column = p.x / 46, row = p.y / 44;