嘿家伙, 我知道它已经被更频繁地询问,但他们的问题的答案似乎并不适用于此。问题UIImagePickerControllerDelegate,didFinishPickingMediaWithInfo没有调用
我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文件:#进口 “ 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个按钮和一个模糊的UIImageView。 'photo'连接到UIImageView,'selectPhoto'和'takePhoto'连接到它们的按钮,'selectPicture'连接到两个按钮'Touch Up Inside-action'。 有人可以帮我吗?
,我不知道我是否应该自己买一些新的眼镜,或只是一头扎进床上。谢谢队友(10分钟后可以接受答案,不知何故) – Joetjah 2011-04-07 12:23:11
没问题。我去过那儿! – CharlieMezak 2011-04-07 12:25:23
你打了我约50秒。所以避免重复的答案和投票你的答案 – visakh7 2011-04-07 12:27:16