0

アプリは写真を撮って選択し、それを画像ビューに割り当てることになっています。すべてが機能しているように見えますが、画像ビューは変更されません。私のコード:

- (IBAction)takePicture:(id)sender
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
// Lazily allocate image picker controller
if (!imagePickerController) {
    imagePickerController = [[UIImagePickerController alloc] init];

    // If our device has a camera, we want to take a picture, otherwise, we just pick from
    // photo library
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        [imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
    }else
    {
        [imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    }
}
// Place image picker on the screen
[self presentViewController:imagePickerController animated:YES completion:nil];

}


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    [self dismissViewControllerAnimated:YES completion:nil];
} else {
    [imagePickerPopover dismissPopoverAnimated:YES];
    imagePickerPopover = nil;
}

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

[imageView setImage:image];
  }
4

2 に答える 2

0

代理人が必要です。追加:

imagePickerController.delegate = self;
于 2013-02-14T02:22:30.470 に答える
0

画像ピッカーのデリゲートを設定していないように思えます。たとえば、それ [imagePickerController setDelegate:self];はあなたのtakePicture方法にあると思います。

于 2013-02-14T02:22:51.300 に答える