-1
 -(IBAction)TakePhoto {
picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentedViewController:picker animated:YES completion:nil];
}

- (IBAction)ChooseExisting {
picker2 = [[UIImagePickerController alloc]init];
picker2.delegate = self;
[picker2 setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentedViewController:picker2 animated:YES completion:nil];
}

- (void) imagePickerController:(UIImagePickerController *)picker    didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageview setImage:image];
[self dismissViewControllerAnimated:YES completion:nil];

}
  - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:NULL];

このアプリを実行しようとすると、

[self presentedViewController:picker animated:YES completion:nil];

No visible @interface for ViewController と言って赤色で強調表示されます 提示されたセクターを宣言しますviewcontroller:animated :completion :

私の.hファイルは

@interface ViewController : UIViewController <UIImagePickerControllerDelegate,
UINavigationControllerDelegate> {
UIImagePickerController *picker;
UIImagePickerController *picker2;
UIImage *image;
IBOutlet UIImageView *imageview;

}

- (IBAction)TakePhoto;
- (IBAction)ChooseExisting;
4

1 に答える 1

2

タイプミスがあります:行presentedViewControllerの代わりにpresentViewController

[self presentedViewController:picker animated:YES completion:nil];

(複数の場所で)

于 2013-07-15T07:21:41.760 に答える