- (IBAction)onUploadImage:(id)sender
{
[self pickphoto:UIImagePickerControllerSourceTypePhotoLibrary];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[imagePicker dismissModalViewControllerAnimated:NO];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
if ([self.popoverController isPopoverVisible])
{
[self.popoverController dismissPopoverAnimated:YES];
[popoverController release];
}
if (image != nil)
{
myImage.image = image;
}
}
}
- (void)pickphoto:(UIImagePickerControllerSourceType)sourceType
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
if ([self.popoverController isPopoverVisible])
{
[self.popoverController dismissPopoverAnimated:YES];
[popoverController release];
}
else
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
imagePicker =[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,(NSString *) kUTTypeMovie,nil];
imagePicker.allowsEditing = NO;
self.popoverController = [[UIPopoverController alloc]initWithContentViewController:imagePicker];
popoverController.delegate = self;
//[self.popoverController presentPopoverFromBarButtonItem: permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[self.popoverController presentPopoverFromRect:CGRectMake(0,900,320,800) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
// [imagePicker release];
}
}
}
else
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.navigationBar.tintColor=[UIColor blackColor];
imagePicker.navigationItem.title=@"Photo Albums";
imagePicker.delegate = self;
imagePicker.sourceType = sourceType;
//[self presentModalViewController:imagePicker animated:YES];
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:imagePicker completion:nil];
//[imagePicker dismissModalViewControllerAnimated:YES];
}
image is not selecting from the gallery
-
26-06-2023 - |
Frage
-(void)Open_Library
{
// Create image picker controller
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
// Set source to the camera
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate=self;
// Delegate is self
// Allow editing of image ?
imagePicker.allowsEditing = YES;
// Show image picker
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
CGRect popoverRect = CGRectMake(10, 10, 200, 200);
[popover presentPopoverFromRect:popoverRect inView:self.imgview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else
{
[self presentViewController:imagePicker animated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage: (UIImage *)img editingInfo:(NSDictionary *)editingInfo
{
_imgview.image = img;
[picker dismissModalViewControllerAnimated:YES];
}
Here image is opened in gallery but not selecting. Here "imgview" is IMAGEVIEW I took for displaying the image selected from the gallery. what i am doing wrong here.i want to display the image selected from gallery.
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow