Skip to content

Commit 76fc38f

Browse files
committed
fixed double tap event
added delegate methods to the sample
1 parent 098c223 commit 76fc38f

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

ios_calendar/Base.lproj/Main_iPad.storyboard

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<constraint firstAttribute="centerY" secondItem="L8L-8V-u8e" secondAttribute="centerY" id="yGd-AZ-eWL"/>
3333
</constraints>
3434
</view>
35+
<connections>
36+
<outlet property="calendarView" destination="L8L-8V-u8e" id="Jd6-2y-JeM"/>
37+
</connections>
3538
</viewController>
3639
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
3740
</objects>

ios_calendar/Base.lproj/Main_iPhone.storyboard

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<constraint firstAttribute="centerX" secondItem="Eap-L3-erN" secondAttribute="centerX" id="36q-nY-zZf"/>
3333
</constraints>
3434
</view>
35+
<connections>
36+
<outlet property="calendarView" destination="Eap-L3-erN" id="j4K-da-Kao"/>
37+
</connections>
3538
</viewController>
3639
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
3740
</objects>

ios_calendar/Sources/CalendarView.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,6 @@ - (void)changeDateEvent
492492
if (_calendarDelegate && [_calendarDelegate respondsToSelector:@selector(didChangeCalendarDate:withType:withEvent:)]) {
493493
[_calendarDelegate didChangeCalendarDate:currentDate withType:type withEvent:event];
494494
}
495-
if (event==CE_DoubleTap && _calendarDelegate && [_calendarDelegate respondsToSelector:@selector(didDoubleTapCalendar:withType:)]) {
496-
[_calendarDelegate didDoubleTapCalendar:currentDate withType:type];
497-
}
498495
}
499496

500497
#pragma mark - Gestures
@@ -657,6 +654,11 @@ - (void)doubleTap:(UITapGestureRecognizer *)recognizer
657654
--type;
658655
[self fade];
659656
}
657+
658+
NSDate *currentDate = [self currentDate];
659+
if (event==CE_DoubleTap && _calendarDelegate && [_calendarDelegate respondsToSelector:@selector(didDoubleTapCalendar:withType:)]) {
660+
[_calendarDelegate didDoubleTapCalendar:currentDate withType:type];
661+
}
660662
}
661663

662664
#pragma mark - Additional functions

ios_calendar/ViewController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
//
88

99
#import <UIKit/UIKit.h>
10+
#import "CalendarView.h"
1011

11-
@interface ViewController : UIViewController
12+
@interface ViewController : UIViewController <CalendarViewDelegate>
1213

1314
@end

ios_calendar/ViewController.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,32 @@
1010

1111
@interface ViewController ()
1212

13+
@property (weak, nonatomic) IBOutlet CalendarView *calendarView;
14+
1315
@end
1416

1517
@implementation ViewController
1618

1719
- (void)viewDidLoad
1820
{
1921
[super viewDidLoad];
20-
// Do any additional setup after loading the view, typically from a nib.
22+
23+
self.calendarView.calendarDelegate = self;
24+
}
25+
26+
- (void)didChangeCalendarDate:(NSDate *)date
27+
{
28+
NSLog(@"didChangeCalendarDate:%@", date);
29+
}
30+
31+
- (void)didChangeCalendarDate:(NSDate *)date withType:(NSInteger)type withEvent:(NSInteger)event
32+
{
33+
NSLog(@"didChangeCalendarDate:%@ withType:%d withEvent:%d", date, type, event);
2134
}
2235

23-
- (void)didReceiveMemoryWarning
36+
- (void)didDoubleTapCalendar:(NSDate *)date withType:(NSInteger)type
2437
{
25-
[super didReceiveMemoryWarning];
26-
// Dispose of any resources that can be recreated.
38+
NSLog(@"didDoubleTapCalendar:%@ withType:%d", date, type);
2739
}
2840

2941
@end

0 commit comments

Comments
 (0)