我使用下面的代碼,我想選擇的顏色傳遞給另一個類,但它給了我下面的警告並不起作用:如何從一個類傳遞的UIColor對象到另一個類
不兼容的指針類型分配給從的UIColor的NSString強:
代碼:
-(IBAction)showpickerview
{
NEOColorPickerViewController *controller = [[NEOColorPickerViewController alloc] init];
controller.delegate = self;
//controller.selectedColor = self.currentColor;
controller.title = @"Select Color";
UINavigationController* navVC = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navVC animated:YES completion:nil];
}
- (void)colorPickerViewController:(NEOColorPickerBaseViewController *)controller didSelectColor:(UIColor *)color
{
SecondClass *second = [[SecondClass alloc]init];
second.selectColor = color;
NSLog(@"selected color %@",second.selectColor);
//UIColor *color1 = color;
//const CGFloat *components = CGColorGetComponents(color.CGColor);
//second.selectColor = [NSString stringWithFormat:@"%f,%f,%f,%f", components[0], components[1], components[2], components[3]];
//NSLog(@"selected color %@",second.selectColor);
[controller dismissViewControllerAnimated:YES completion:nil];
}
什麼是警告? – Peres
你如何調用colorPickerViewController? –
不兼容的指針類型從uicolor強分配給nsstring強 –