i cannot seem to get this right. ive looked at several tutorials with no luck. i realize it is a simple task, which is why i am so confused on why it isnt working for me.
i have a programmatically made button inside an expanding cell and when you press it, it is suppose to access the camera to take a picture. i have this code:
- (void)buttonPressed:(UIButton *)button {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[picker setDelegate:self];
//picker.allowsImageEditing = NO;
[self presentModalExpandingCell:picker animated:YES];
picker.showsCameraControls = YES;
}
the error appears in line 5. and says "no visible #interface for 'ExpandingCell' declares the selector 'presentModalExpandingCell:animated:'" i have "" in the .h file so i have no idea what to do.
any help will be greatly appreciated. thanks in advance.
Have you declared the method "presentModalExpandingCell" in your class? Because, if not, that is why the compiler is throwing that error.
Related
In my code , uiimagepickerviewcontroll is not selecting image on touch , it selects image either on swipe on the image or very long press.
I've not added any special code below is the code I've used.
self.imagePickerController = [[UIImagePickerController alloc] init];
_imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
_imagePickerController.allowsEditing = NO;
_imagePickerController.delegate = self;
[self.navigationController pushViewController:self.imagePickerController animated:YES];
if any one have any solution , please help me.
Thanks.
Hi, try this way, working always correct for me:
UIImagePickerController *imagePicker = [UIImagePickerController new];
imagePicker.delegate = self;
imagePicker.mediaTypes = #[(NSString*) kUTTypeImage];
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum ;
_libraryImagePickerController = imagePicker;
Hope it helps :)
I don't know why this issue came, but I found only 1 solution, created a new project and copied whole code to the new one.
Issue was automatically resolved.
I am presently using UIImagePicker and my app crashes on iOS 8 with the following workflow:
Start the camera, zoom it which shows the zoom slider below and then take a picture. Select Use Photo and app crashes.
After looking more into the crash "didHideZoomSlider" message is sent to the deallocated instance of image picker view.
Here is my code:
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeImage, nil];
imagePicker.allowsEditing = YES;
imagePicker.delegate = self;
[myController presentViewController:imagePicker animated:animated completion:nil];
I tried a couple of things. My controller holds a strong reference to the image picker, I tried making it a weak reference and the app still crashes. Also I need a strong reference so I actually cannot make it weak.
Although this looks like an Apple bug and someone has already logged it (http://openradar.appspot.com/18762927) I wanted to try the workaround they are using. However I am not able to get to "CAMZoomSlider" through UIImagePicker's instance.
Does anyone know how to get to CAMZoomSlider?
I was able to clear the CAZoomSlider delegate by doing the following in a subclassed UIImagePickerController class. And sure enough, it seems to have resolved the crash.
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self clearZoomSliderDelegate:self.view.subviews];
}
- (void)clearZoomSliderDelegate:(NSArray*)subviews
{
for (UIView *subview in subviews)
{
if ([subview isKindOfClass:NSClassFromString(#"CAMZoomSlider")])
{
if ([subview respondsToSelector:#selector(setDelegate:)]) {
[subview performSelector:#selector(setDelegate:) withObject:nil];
}
return;
}
else if (subview.subviews != nil) {
[self clearZoomSliderDelegate:subview.subviews];
}
}
}
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];
}
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.
Iphone app, IOS 5 and up.
There are similar questions to this one on SO but I haven't encountered this exact scenario so I'll ask. I'm editing an existing app that allows lets you take a photo which it resizes and sends to a web service.
I need to add the ability to take 3 photos, resize each and send to the same service. I thought it would be just a matter of repeating what was already in the app but it uses the UIImagePickerController which apparently only allows one photo per use.
So the way it works is that there's a 'Take Photo' button which calls the method below. Once that photo is taken another button appears that says 'Take another photo' (I added this button) and I have it calling the same method but it is just copying over the previous photo, which is to be expected really. How should I best alter this to accommodate 3 photos?
This is the takephoto method that I'm calling.
- (IBAction)takePhoto:(id)sender
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:NULL];
}
check this https://developer.apple.com/library/ios/samplecode/photopicker/Introduction/Intro.html
, check the take photo part of this demo project.
Eventually figured out how to do this. I added a tag to the button calling the method, through IB.
Then in the takephoto method I assigned the imagePickerController a tag based on the tag of the button that tapped. Like this:
- (IBAction)takePhoto:(id)sender
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if([sender tag] == 2)
{
imagePickerController.view.tag = 2;
}
//And so on...
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:NULL];
}
Then in the ImagePickerController didFinishedPickingMediaWithInfo method:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if(picker.view.tag == 2)
{
//Do stuff here
}
}
So, I'll probably have to create three different buttons for each of the three possible photos, I'm sure there's a better way than that but it should work.
I know this thread existed before, but was closed as only appearing in iOS5 beta 6.
By now I have the Golden Master of iOS 5 on my phone and that error still appears.
This is happening when I create a UIImagePickerController with a sourceType of UIImagePickerControllerSourceTypePhotoLibrary more than 5 times. I am, as far as I can tell, creating and releasing the previous UIImagePickerController correctly each time.
Edit: adding code, as requested.
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:ipc animated:YES];
[ipc release];
Later, I call [self dismissModalViewControllerAnimated:YES]; when -imagePickerController:didFinishPickingImage:editingInfo: gets called.
The problem happens in Apple examples, so the best bet is to ignore.
Later, I call [self dismissModalViewControllerAnimated:YES]; when
-imagePickerController:didFinishPickingImage:editingInfo: gets called.
Have you tried to set the delegate of the image picker to nil, in didFinishPickingImage ?
This is not your fault.It may be vary in different version.Apple should solve this issue.Main thing is that you should check for memory leak is important.Thanks
Try this UIImagePickerControllerSourceTypePhotoLibrary Error
I hope it will help
try setting
picker=nil
in the
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissModalViewControllerAnimated:YES];
picker = nil;
}
it works for me......
Try this one, i am sure this is gonna help you;
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setModalInPopover:YES];
}