Question

I'm trying to incorporate a colorpicker into my app. I've copied over the KZColorPicker library into my project from https://github.com/alexrestrepo/KZColorPicker

The problem is that the library apparently was created without using ARC. I'm using ARC so I got a ton of errors, which I then commented out all the release statements that were erroring.

After instantiating the "KZDefaultColorViewController", it will get to the ViewDidLoad statement but give me a "EXC_BAD_ACCESS code=1" error. Any ideas???

Here's my IBAction that initiates the colorpicker screen:

- (IBAction)selectColor1:(id)sender
{
 DebugLog(@"Change Color 1 Intiated");

// Use this code to push to the color picker
 KZDefaultColorViewController *pickerController = [self.storyboard instantiateViewControllerWithIdentifier:@"ColorViewController"];
 pickerController.navigationItem.title = @"Choose Color 1";
 [self.navigationController pushViewController:pickerController animated:YES];
}

Then it goes to KZDefaultColorViewController's ViewDidLoad where it seems I get the EXC_BAD_ACCESS error:

- (void)viewDidLoad {

 [super viewDidLoad];

 KZColorPicker *picker = [[KZColorPicker alloc] initWithFrame:self.view.frame];
 picker.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
 picker.selectedColor = self.selectedColor;
 picker.oldColor = self.selectedColor;
 [picker addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
 [self.view addSubview:picker];

}
Était-ce utile?

La solution

I converted this project to arc after removing the line about [_window release]; and fixing the IS_IPAD definition to just be 0 for now, without issue. (via the Edit menu, under Refactor, convert to Arc)

If you copied some of the project to your own, the error is probably due to either not implementing the KZDefaultColorControllerDelegate properly, or you're missing the pickerChanged: method in your code.. or not converting to arc first. Commenting out release statements won't necessarily fix all arc issues.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top