【发布时间】:2011-04-07 12:17:33
【问题描述】:
大家好, 我知道这个问题被问得更频繁了,但他们的问题的答案似乎在这里并不适用。
我的 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 文件: #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 个按钮和一个空的 UIImageView。 'photo' 连接到 UIImageView,'selectPhoto' 和 'takePhoto' 连接到它们的按钮,'selectPicture' 连接到两个按钮'Touch Up Inside-action。 谁能帮帮我?
【问题讨论】:
标签: iphone objective-c xcode camera xcode4