Commits

Markus Müller committed 1d62c99

Added support for iPad. Added new optional delegate methode for continous color updates.

Comments (0)

Files changed (3)

Classes/MNColorPicker.h

 	MNColorWheelView *_colorWheelView;
 	MNBrightnessView *_brightnessView;
 	UIColor *_color;
+	BOOL _continuous;
 }
 
-@property (readwrite,assign, nonatomic) id<MNColorPickerDelegate> delegate;
-@property (readwrite, retain) UIColor *color;
+@property (assign, nonatomic) id<MNColorPickerDelegate> delegate;
+@property (retain) UIColor *color;
+@property (getter=isContinuous) BOOL continuous;
+
 
 
 @end
 @required
 - (void)colorPicker:(MNColorPicker *)picker didFinishWithColor:(UIColor *)color;
 
+@optional
+- (void)colorPicker:(MNColorPicker *)picker didChangeColor:(UIColor *)color;
+
 @end

Classes/MNColorPicker.m

 	self = [super initWithNibName:nil bundle:nil];
 	if (self != nil) {
 		self.color = [UIColor whiteColor];
+		self.continuous = NO;
+		if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+			self.contentSizeForViewInPopover = CGSizeMake(320, 420);
+		}		
 	}
 	return self;
 }
 
 @synthesize delegate=_delegate;
 @synthesize color=_color;
+@synthesize continuous=_continuous;
 
 
 #pragma mark -
 #pragma mark Layout
 
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
-    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
+{
+	if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+		return YES;
+	} else {
+		return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+	}
 }
 
 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
 - (void)colorWheelView:(MNColorWheelView *)colorWheelView didChangeColor:(UIColor *)color {
 	self.color = color;
 	_colorView.color = color;
+	
+	if (self.continuous && [self.delegate respondsToSelector:@selector(colorPicker:didChangeColor:)]) {
+		[self.delegate performSelector:@selector(colorPicker:didChangeColor:) withObject:self withObject:self.color];
+	}
 }
 
 

MNColorPicker.xcodeproj/project.pbxproj

 			isa = PBXProject;
 			buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "MNColorPicker" */;
 			compatibilityVersion = "Xcode 3.1";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 3.0;
 				PREBINDING = NO;
-				SDKROOT = iphoneos3.0;
+				SDKROOT = iphoneos4.1;
 			};
 			name = Debug;
 		};