UIImagePickerController вопрос - PullRequest
0 голосов
/ 29 июля 2009

В моем приложении у меня есть два контроллера представления. MainViewController переключается на AlbumViewController при нажатии кнопки. Предполагается, что AlbumVC позволяет пользователю выбрать изображение из PhotoLibrary и / или CameraRoll. Итак, я пытаюсь запустить UIImagePickerController.

Однако, когда приложение запускается, я вообще не вижу UIImagePickerController. Не ошибки компилятора и ошибки времени выполнения.

Может ли какая-то добрая душа помочь мне!

Вот источник ..... Сэм

MainViewController.h

    #import <UIKit/UIKit.h>

    @interface iNotateViewController : UIViewController {

    }

@end

MainViewController.m

#import "iNotateViewController.h"

@implementation iNotateViewController

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}

@end

AlbumViewController.h

#import <UIKit/UIKit.h>
#import <UIKit/UIViewController.h>

@interface AlbumViewController : UIViewController <UINavigationControllerDelegate,
                                                    UIImagePickerControllerDelegate >{

}
@end

AlbumViewController.m

    - (void)viewDidLoad {

        [super viewDidLoad];

        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
            UIImagePickerController *picker;
            picker = [[UIImagePickerController alloc] init];
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            picker.allowsImageEditing = YES;

            picker.delegate = self;

            [self presentModalViewController:picker animated:YES];

            [picker release];       
        }
    }


    -(void)imagePickerController: (UIImagePickerController *) picker
           didFinishPickingImage: (UIImage *) image
                     editingInfo: (NSDictionary *) editingInfo {
        [self useImage:image];
        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }

    -(void)imagePickerControllerDidCancel: (UIImagePickerController *)picker {
        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    }
@end

Ответы [ 2 ]

0 голосов
/ 15 февраля 2011

В AlbumViewController.m изменить следующую строку кода в методе - (void)viewDidLoad

От:

[self presentModalViewController:picker animated:YES];

Кому:

[self.navigationController presentModalViewController:picker animated:YES];
0 голосов
/ 29 июля 2009

Полагаю, вам следует переместить [выпуск сборщика] в метод dealloc

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...