Joe*_*jah 1 iphone xcode camera objective-c xcode4
嘿伙计们,我知道它经常被问到,但他们问题的答案似乎并不适用于此.
我的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
Run Code Online (Sandbox Code Playgroud)
.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
Run Code Online (Sandbox Code Playgroud)
因此,我的相册或相机被正确加载/激活,但是当我点击"使用"或照片时,我只会在视图被解除后看到2个按钮和一个emtpy UIImageView.'photo'连接到UIImageView,'selectPhoto'和'takePhoto'连接到它们的按钮,'selectPicture'连接到两个按钮的Touch Up Inside-action.有人可以帮帮我吗?
您的delegete方法中有拼写错误.
它应该是
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Run Code Online (Sandbox Code Playgroud)
但是你有
- (void)imagePickController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4075 次 |
| 最近记录: |