Permalink
Browse files

At the request of Hakan Durmaz, I have made the calendar not call the…

… delegate method when no date is selected and the user cancels the operation.
  • Loading branch information...
1 parent b9c2141 commit 30ac4db2820c64278980890da96a63a7248d4a21 Oliver Rickard committed Sep 6, 2012
View
@@ -8,4 +8,5 @@
*.perspectivev3
*.xcuserstate
project.xcworkspace/
-xcuserdata/
+xcuserdata/
+Demo/build/
@@ -277,10 +277,12 @@
B1558BF7152648CB00326469 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CODE_SIGN_IDENTITY = "iPhone Developer: Oliver Rickard (M2X353B497)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCCalendar/OCCalendar-Prefix.pch";
INFOPLIST_FILE = "OCCalendar/OCCalendar-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE = "C183E71C-4BA9-4B64-B7E5-BA551FF1F744";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
@@ -29,6 +29,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.viewController = [[[OCViewController alloc] initWithNibName:@"OCViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
+
+ NSLog(@"%s", __PRETTY_FUNCTION__);
return YES;
}
@@ -87,6 +87,8 @@ - (void)completedWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateStyle:NSDateFormatterShortStyle];
+ NSLog(@"startDate:%@, endDate:%@", startDate, endDate);
+
[self showToolTip:[NSString stringWithFormat:@"%@ - %@", [df stringFromDate:startDate], [df stringFromDate:endDate]]];
[df release];
@@ -24,7 +24,6 @@ typedef enum {
int currentMonth;
int currentYear;
- BOOL selected;
int startCellX;
int startCellY;
int endCellX;
@@ -48,6 +47,8 @@ typedef enum {
- (NSDate *)getStartDate;
- (NSDate *)getEndDate;
+- (BOOL)selected;
+
- (void)setStartDate:(NSDate *)sDate;
- (void)setEndDate:(NSDate *)eDate;
@@ -46,8 +46,6 @@ - (id)initAtPoint:(CGPoint)p withFrame:(CGRect)frame arrowPosition:(OCArrowPosit
currentYear = [dateParts year];
arrowPosition = arrowPos;
-
- selected = NO;
startCellX = -1;
startCellY = -1;
endCellX = -1;
@@ -143,6 +141,11 @@ - (void)resetViews {
[UIView commitAnimations];
}
+- (BOOL)selected {
+ //NSLog(@"Selected:%d", [selectionView selected]);
+ return [selectionView selected];
+}
+
- (void)setArrowPosition:(OCArrowPosition)pos {
arrowPosition = pos;
}
@@ -100,13 +100,19 @@ - (void)removeCalView {
//NSLog(@"startDate:%@ endDate:%@", startDate.description, endDate.description);
+ //NSLog(@"CalView Selected:%d", [calView selected]);
+
+ if([calView selected]) {
+ if([startDate compare:endDate] == NSOrderedAscending)
+ [self.delegate completedWithStartDate:startDate endDate:endDate];
+ else
+ [self.delegate completedWithStartDate:endDate endDate:startDate];
+ } else {
+ //Do something else if it's not selected.
+ }
+
[calView removeFromSuperview];
calView = nil;
-
- if([startDate compare:endDate] == NSOrderedAscending)
- [self.delegate completedWithStartDate:startDate endDate:endDate];
- else
- [self.delegate completedWithStartDate:endDate endDate:startDate];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
@@ -30,5 +30,6 @@
-(void)setStartPoint:(CGPoint)sPoint;
-(void)setEndPoint:(CGPoint)ePoint;
@property(nonatomic, assign) OCSelectionMode selectionMode;
+@property (nonatomic, assign) BOOL selected;
@end
@@ -10,6 +10,7 @@
@implementation OCSelectionView
@synthesize selectionMode = _selectionMode;
+@synthesize selected;
- (id)initWithFrame:(CGRect)frame
{
@@ -34,6 +35,10 @@ - (id)initWithFrame:(CGRect)frame
return self;
}
+- (BOOL) selected {
+ return selected;
+}
+
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
@@ -74,7 +79,7 @@ - (void)drawRect:(CGRect)rect
if(endCellY == i) {
thisRowEndCell = endCellX;
-// } else {
+
if (startCellY > endCellY) {
thisRowStartCell = endCellX; thisRowEndCell = 6;
}
@@ -108,7 +113,7 @@ - (void)drawRect:(CGRect)rect
}
-(void) singleSelection:(NSSet *)touches {
- selected = YES;
+ self.selected = YES;
UITouch *touch = [touches anyObject];

2 comments on commit 30ac4db

Contributor

markrickert replied Sep 6, 2012

Not a bad change IMHO.

Owner

ocrickard replied Sep 7, 2012

Agreed. The previous behavior was somewhat unexpected to the user. Thanks Hakan!

Please sign in to comment.