In these methods....
- (void) avatarPressed:(id)sender
{
buttonPressed = 2;
if (self.image == nil) {
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = NO;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[self performSelector:@selector(takePhoto) withObject:nil];
} else {
[self performSelector:@selector(chooseFromLibrary) withObject:nil];
}
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:self.imagePicker.sourceType];
[self presentViewController:self.imagePicker animated:NO completion:nil];
}
}
You are performing a couple of selectors, which themselves present an image picker, and then straight after those if statements you are presenting another image picker.
Think your methods should look like this
- (void) avatarPressed:(id)sender
{
buttonPressed = 2;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[self performSelector:@selector(takePhoto) withObject:nil];
} else {
[self performSelector:@selector(chooseFromLibrary) withObject:nil];
}
}