Проблема UIImagePickerControllerDelegate, didFinishPickingMediaWithInfo не вызывается - PullRequest
1 голос
/ 07 апреля 2011

Эй, ребята, я знаю, что об этом спрашивали чаще, но ответы на их вопросы здесь не годятся.

Мой метод didFinishPickingMediaWithInfo не вызывается: (

Вот мой код:

.h-файл:

#import <UIKit/UIKit.h>


@interface DevicePictureController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {

    UIImageView *photo;
    UIButton *selectPhoto;
    UIButton *takePhoto;
    NSMutableDictionary *listLocations;
    NSMutableDictionary *listDevices;
    UIImagePickerController *picker;
}

@property (nonatomic, retain) IBOutlet UIImageView *photo;
@property (nonatomic, retain) IBOutlet UIButton *selectPhoto;
@property (nonatomic, retain) IBOutlet UIButton *takePhoto;
@property (nonatomic, retain) UIImagePickerController *picker;

-(IBAction)selectPicture:(id)sender;
@end

.m-file: #import "DevicePictureController.h"

@implementation DevicePictureController
@synthesize photo, selectPhoto, takePhoto, picker;

- (void)viewDidLoad
{
    [super viewDidLoad];
    listLocations = [[NSMutableDictionary alloc] init];
    listDevices = [[NSMutableDictionary alloc] init];
    picker = [[UIImagePickerController alloc] init];
}

-(IBAction)selectPicture:(id)sender {

    picker.delegate = self;
    picker.allowsEditing = YES;

    if ((UIButton *)sender == selectPhoto)  {

        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    else {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }

    [self presentModalViewController:picker animated:YES];
}

-(void)imagePickController:(UIImagePickerController *)picked didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picked dismissModalViewControllerAnimated:YES];
    NSLog(@"Geselecteerd: %@", [info objectForKey:UIImagePickerControllerEditedImage]);
    //photo = [[UIImageView alloc] init];
    [photo setImage:[info objectForKey:UIImagePickerControllerEditedImage]];
}

@end

Итак, мой альбом или моя камера загружаются / активируются правильно, но когда я нажимаю «Использовать» или фотографию, я вижу только 2 кнопкии emtpy UIImageView после того, как представление отклонено. 'photo' подключено к UIImageView, 'selectPhoto' и 'takePhoto' подключены к их кнопкам, 'selectPicture' подключено к обеим кнопкам 'Touch Up Inside-action. Может кто-нибудь помочьменя нет?

Ответы [ 2 ]

5 голосов
/ 07 апреля 2011

У вас есть опечатка в вашем методе delegete.

должно быть

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

но у вас есть

- (void)imagePickController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
1 голос
/ 07 апреля 2011
- (void)viewDidLoad
{
[super viewDidLoad];
listLocations = [[NSMutableDictionary alloc] init];
listDevices = [[NSMutableDictionary alloc] init];
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...